diff --git a/docs/gateway/config-agents.md b/docs/gateway/config-agents.md index 37c6f1d9766a..d4496f9f0343 100644 --- a/docs/gateway/config-agents.md +++ b/docs/gateway/config-agents.md @@ -634,7 +634,7 @@ Periodic heartbeat runs. compaction: { mode: "safeguard", // default | safeguard provider: "my-provider", // id of a registered compaction provider plugin (optional) - timeoutSeconds: 900, + timeoutSeconds: 180, reserveTokensFloor: 24000, keepRecentTokens: 50000, identifierPolicy: "strict", // strict | off | custom @@ -661,7 +661,7 @@ Periodic heartbeat runs. - `mode`: `default` or `safeguard` (chunked summarization for long histories). See [Compaction](/concepts/compaction). - `provider`: id of a registered compaction provider plugin. When set, the provider's `summarize()` is called instead of built-in LLM summarization. Falls back to built-in on failure. Setting a provider forces `mode: "safeguard"`. See [Compaction](/concepts/compaction). -- `timeoutSeconds`: maximum seconds allowed for a single compaction operation before OpenClaw aborts it. Default: `900`. +- `timeoutSeconds`: maximum seconds allowed for a single compaction operation before OpenClaw aborts it. Default: `180`. - `keepRecentTokens`: agent cut-point budget for keeping the most recent transcript tail verbatim. Manual `/compact` honors this when explicitly set; otherwise manual compaction is a hard checkpoint. - `identifierPolicy`: `strict` (default), `off`, or `custom`. `strict` prepends built-in opaque identifier retention guidance during compaction summarization. - `identifierInstructions`: optional custom identifier-preservation text used when `identifierPolicy=custom`. diff --git a/src/agents/embedded-agent-runner.compaction-safety-timeout.test.ts b/src/agents/embedded-agent-runner.compaction-safety-timeout.test.ts index 8f47d02a5ee6..266e7d90ac24 100644 --- a/src/agents/embedded-agent-runner.compaction-safety-timeout.test.ts +++ b/src/agents/embedded-agent-runner.compaction-safety-timeout.test.ts @@ -125,6 +125,14 @@ describe("resolveCompactionTimeoutMs", () => { }); it("converts timeoutSeconds to milliseconds", () => { + expect( + resolveCompactionTimeoutMs({ + agents: { defaults: { compaction: { timeoutSeconds: 120 } } }, + }), + ).toBe(120_000); + }); + + it("preserves explicit timeoutSeconds above 600", () => { expect( resolveCompactionTimeoutMs({ agents: { defaults: { compaction: { timeoutSeconds: 1800 } } }, diff --git a/src/agents/embedded-agent-runner/compaction-safety-timeout.ts b/src/agents/embedded-agent-runner/compaction-safety-timeout.ts index 564b4cfa5412..beba651420b4 100644 --- a/src/agents/embedded-agent-runner/compaction-safety-timeout.ts +++ b/src/agents/embedded-agent-runner/compaction-safety-timeout.ts @@ -6,7 +6,7 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js"; import type { CompactResult, ContextEngine } from "../../context-engine/types.js"; import { withTimeout } from "../../node-host/with-timeout.js"; -export const EMBEDDED_COMPACTION_TIMEOUT_MS = 900_000; +export const EMBEDDED_COMPACTION_TIMEOUT_MS = 180_000; function createAbortError(signal: AbortSignal): Error { const reason = "reason" in signal ? signal.reason : undefined; diff --git a/src/agents/embedded-agent-runner/run/attempt.run-decisions.ts b/src/agents/embedded-agent-runner/run/attempt.run-decisions.ts index f9ef74879ac4..97a416045a66 100644 --- a/src/agents/embedded-agent-runner/run/attempt.run-decisions.ts +++ b/src/agents/embedded-agent-runner/run/attempt.run-decisions.ts @@ -20,7 +20,7 @@ export function resolveEmbeddedAttemptSessionWriteLockOptions(params: { env?: NodeJS.ProcessEnv; }): { timeoutMs: number; staleMs: number; maxHoldMs: number } { // Bound embedded-attempt lock holds to the compaction window, not the full run timeout. - // With defaults this permits roughly 900s compaction time plus the shared 120s + // With defaults this permits roughly 180s compaction time plus the shared 120s // timeout grace before the watchdog releases a stuck live-process lock. return resolveSessionWriteLockOptions(params.config, { env: params.env, diff --git a/src/config/schema.help.ts b/src/config/schema.help.ts index 9f2a0de4732f..6a198388c99c 100644 --- a/src/config/schema.help.ts +++ b/src/config/schema.help.ts @@ -1494,7 +1494,7 @@ export const FIELD_HELP: Record = { "agents.defaults.compaction.postCompactionSections": 'Opt-in AGENTS.md H2/H3 section names re-injected after compaction so the agent reruns critical startup guidance. Leave unset or set [] to disable reinjection. Explicitly set ["Session Startup", "Red Lines"] to enable the legacy default pair with fallback to older "Every Session"/"Safety" headings. Enabling this can duplicate project context already present in the compaction summary.', "agents.defaults.compaction.timeoutSeconds": - "Maximum time in seconds allowed for a single compaction operation before it is aborted (default: 900). Increase this for very large sessions that need more time to summarize, or decrease it to fail faster on unresponsive models.", + "Maximum time in seconds allowed for a single compaction operation before it is aborted (default: 180). Increase this for very large sessions that need more time to summarize, or decrease it to fail faster on unresponsive models.", "agents.defaults.compaction.model": "Optional provider/model override used only for compaction summarization. Set this when you want compaction to run on a different model than the session default, and leave it unset to keep using the primary agent model.", "agents.defaults.compaction.truncateAfterCompaction": diff --git a/src/config/types.agent-defaults.ts b/src/config/types.agent-defaults.ts index b5b627358004..b5233ebb87c9 100644 --- a/src/config/types.agent-defaults.ts +++ b/src/config/types.agent-defaults.ts @@ -541,7 +541,7 @@ export type AgentCompactionConfig = { * When set, compaction uses this model instead of the agent's primary model. * Falls back to the primary model when unset. */ model?: string; - /** Maximum time in seconds for a single compaction operation (default: 900). */ + /** Maximum time in seconds for a single compaction operation (default: 180). */ timeoutSeconds?: number; /** * Id of a registered compaction provider plugin.