Skip to content

Commit bb6e477

Browse files
fix(compaction): lower default timeout from 900s to 180s, preserve explicit config (#91361)
Merged via squash. Prepared head SHA: ac54596 Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: velvet-shark <[email protected]> Reviewed-by: @velvet-shark
1 parent 050c081 commit bb6e477

6 files changed

Lines changed: 14 additions & 6 deletions

File tree

docs/gateway/config-agents.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ Periodic heartbeat runs.
634634
compaction: {
635635
mode: "safeguard", // default | safeguard
636636
provider: "my-provider", // id of a registered compaction provider plugin (optional)
637-
timeoutSeconds: 900,
637+
timeoutSeconds: 180,
638638
reserveTokensFloor: 24000,
639639
keepRecentTokens: 50000,
640640
identifierPolicy: "strict", // strict | off | custom
@@ -661,7 +661,7 @@ Periodic heartbeat runs.
661661

662662
- `mode`: `default` or `safeguard` (chunked summarization for long histories). See [Compaction](/concepts/compaction).
663663
- `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).
664-
- `timeoutSeconds`: maximum seconds allowed for a single compaction operation before OpenClaw aborts it. Default: `900`.
664+
- `timeoutSeconds`: maximum seconds allowed for a single compaction operation before OpenClaw aborts it. Default: `180`.
665665
- `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.
666666
- `identifierPolicy`: `strict` (default), `off`, or `custom`. `strict` prepends built-in opaque identifier retention guidance during compaction summarization.
667667
- `identifierInstructions`: optional custom identifier-preservation text used when `identifierPolicy=custom`.

src/agents/embedded-agent-runner.compaction-safety-timeout.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ describe("resolveCompactionTimeoutMs", () => {
125125
});
126126

127127
it("converts timeoutSeconds to milliseconds", () => {
128+
expect(
129+
resolveCompactionTimeoutMs({
130+
agents: { defaults: { compaction: { timeoutSeconds: 120 } } },
131+
}),
132+
).toBe(120_000);
133+
});
134+
135+
it("preserves explicit timeoutSeconds above 600", () => {
128136
expect(
129137
resolveCompactionTimeoutMs({
130138
agents: { defaults: { compaction: { timeoutSeconds: 1800 } } },

src/agents/embedded-agent-runner/compaction-safety-timeout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js";
66
import type { CompactResult, ContextEngine } from "../../context-engine/types.js";
77
import { withTimeout } from "../../node-host/with-timeout.js";
88

9-
export const EMBEDDED_COMPACTION_TIMEOUT_MS = 900_000;
9+
export const EMBEDDED_COMPACTION_TIMEOUT_MS = 180_000;
1010

1111
function createAbortError(signal: AbortSignal): Error {
1212
const reason = "reason" in signal ? signal.reason : undefined;

src/agents/embedded-agent-runner/run/attempt.run-decisions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function resolveEmbeddedAttemptSessionWriteLockOptions(params: {
2020
env?: NodeJS.ProcessEnv;
2121
}): { timeoutMs: number; staleMs: number; maxHoldMs: number } {
2222
// Bound embedded-attempt lock holds to the compaction window, not the full run timeout.
23-
// With defaults this permits roughly 900s compaction time plus the shared 120s
23+
// With defaults this permits roughly 180s compaction time plus the shared 120s
2424
// timeout grace before the watchdog releases a stuck live-process lock.
2525
return resolveSessionWriteLockOptions(params.config, {
2626
env: params.env,

src/config/schema.help.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ export const FIELD_HELP: Record<string, string> = {
14941494
"agents.defaults.compaction.postCompactionSections":
14951495
'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.',
14961496
"agents.defaults.compaction.timeoutSeconds":
1497-
"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.",
1497+
"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.",
14981498
"agents.defaults.compaction.model":
14991499
"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.",
15001500
"agents.defaults.compaction.truncateAfterCompaction":

src/config/types.agent-defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ export type AgentCompactionConfig = {
541541
* When set, compaction uses this model instead of the agent's primary model.
542542
* Falls back to the primary model when unset. */
543543
model?: string;
544-
/** Maximum time in seconds for a single compaction operation (default: 900). */
544+
/** Maximum time in seconds for a single compaction operation (default: 180). */
545545
timeoutSeconds?: number;
546546
/**
547547
* Id of a registered compaction provider plugin.

0 commit comments

Comments
 (0)