-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Bug: preflight (budget-triggered) compaction hard-capped at ~60s, ignores compaction.timeoutSeconds #95553
Copy link
Copy link
Open
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Priority
None yet
Bug: preflight (budget-triggered) compaction is hard-capped at ~60s by the reply-operation abort, ignores
compaction.timeoutSeconds, and cannot be disabled or extended via configAffected version:
[email protected](mechanism long-standing — preflight-timeout log lines observed back to 2026-05-22; confirmed still present in 2026.6.9)Summary
OpenClaw runs two distinct compaction paths with two different effective timeouts:
trigger=overflow/timeout_recoveryresolveCompactionTimeoutMs(cfg)=agents.defaults.compaction.timeoutSeconds ?? 9e5trigger=budget/cli_budgetreplyOperation.abortSignal(NOT config-derived)runPreflightCompactionIfNeeded(agent-runner.runtime) fires before a turn whentotalTokens >= contextWindow - reserveTokensFloor - softThresholdTokensand callscompactEmbeddedAgentSession({ trigger: "budget", abortSignal: replyOperation.abortSignal }). InsidecompactEmbeddedAgentSessionthe work races the configurable 15-min safety timeout against that abort signal — but for the preflight path the reply-operation abort wins at ~60s, socompaction.timeoutSecondshas no effect on this path.On backends where summarizing a large context legitimately takes longer than 60s (big window + slower self-hosted model), preflight compaction can never complete: it times out at ~60s on every large turn, wastes those 60s, holds the session write lock for the duration, and then the turn proceeds un-compacted and falls through to overflow recovery anyway. Net effect: pure overhead before every large turn, plus added session-write-lock contention.
There is no config to (a) extend the preflight budget, or (b) disable preflight compaction. Compaction config keys are limited to
enabled,mode,model,provider,reserveTokensFloor,softThresholdTokens,timeoutSeconds,maxHistoryShare,memoryFlush,maxActiveTranscriptBytes,midTurnPrecheck,keepRecentTokens. None gates preflight.compaction.enabled: falseis the only global switch and it also disables overflow recovery, so it is not a viable workaround for a long-running agent. SettingmemoryFlush.enabled: falsedoes not disable preflight.Impact
SessionWriteLockTimeoutError/EmbeddedAttemptSessionTakeoverErroron concurrent same-session traffic.Evidence
Paired compaction durations:
So a 60s bound is structurally impossible for this path: real compactions on this backend take ~278s median.
Environment
openai-completions→ vLLM, compaction modelvllm/qwen3.6-fp8-fastreserveTokensFloor20000,softThresholdTokens10000Code references
agent-runner.runtime-*.js—runPreflightCompactionIfNeeded(~L650),trigger: "budget",abortSignal: params.replyOperation.abortSignal;shouldRunPreflightCompaction/resolveMemoryFlushGateStatecompact-*.js—compactWithSafetyTimeout(..., compactionTimeoutMs, { abortSignal: params.abortSignal });[compaction-diag] end ... reason=${failureReason}tool-result-middleware-*.js—resolveCompactionTimeoutMs,EMBEDDED_COMPACTION_TIMEOUT_MS = 9e5Update (v2026.6.9)
Still present. Additional log evidence and a secondary failure mode confirmed by tracing the dist source.
Secondary failure chain: preflight abort → genuine overflow
When preflight compaction times out, the session remains near-full. On the next turn the context genuinely exceeds the window and triggers overflow-path compaction with
willRetry=true— but that compaction also fails because it hits the preflight context too.Log evidence (Jun 19–21 2026):
The overflow-incomplete events (
willRetry=false) indicate the overflow recovery also bails without retrying — the 60s signal fires during the overflow path too, not just the budget path.PR#91737 does not fix this
PR#91737 (merged 2026-06-10, not yet released as of 2026.6.9) fixes persisted totalTokens for cron session snapshots. It does not touch replyOperation.abortSignal, runPreflightCompactionIfNeeded, or the budget/cli_budget compaction path.
maxHistoryShare is not the trigger (clarification)
maxHistoryShare controls how much history is retained after compaction — it is evaluated only once compaction is already running. The compaction trigger does not read maxHistoryShare.
Proposed fix
Either:
agents.defaults.compaction.timeoutSecondsfor the preflight/budget path too (dont let the reply-operation abort cap it below the configured compaction budget), oragents.defaults.compaction.preflight: falseto skip preflight compaction entirely (turns then rely on overflow recovery, which already has the 15-min budget).Option 2 is the minimal, safe escape hatch for slow-backend deployments.