Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
Both threshold and overflow in-turn compaction paths mark themselves incomplete at 60s and discard a valid compaction result that the provider already returned — the hardcoded COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS = 6e4 outer wait fires before the summary model call finishes (~150–190s on a ~200K-token session), causing the session to drift into overflow and stay there.
Steps to reproduce
- Run a long session until context reaches ~200K tokens.
- Complete an assistant turn — checkCompaction fires compact$1 post-turn.
- Observe: gateway logs embedded run auto-compaction incomplete at exactly 60s.
- Observe: trajectory shows prompt.submitted followed by model.completed (aborted=False) at ~143–187s — after the 60s mark.
- The compaction result is discarded. Repeat on the next turn; overflow retries follow the same pattern.
Deterministic trigger: any session where the compaction summary model call takes >60s. A ~200K-token session on anthropic/claude-sonnet-4-6 reliably produces call durations of 143–187s and reproduces on every attempt.
Expected behavior
The compaction model call completes with valid output (aborted=False, confirmed by trajectory) — that result should be consumed and the session compacted. Instead, the embedded attempt abandons the wait at 60s and discards the result. Expected: the outer wait either runs to call completion and consumes the result, or cancels the call on abandon (aborted=True) rather than paying for a full provider call and discarding it.
Actual behavior
Gateway logs embedded run auto-compaction incomplete at exactly 60s on every attempt. Trajectory 91f28c2c (June 17, OpenClaw 2026.6.7-beta.1, anthropic/claude-sonnet-4-6) shows prompt.submitted followed by model.completed (aborted=False, externalAbort=False, timedOut=False) at 143s, 174s, and 187s respectively — the call completed successfully at the provider but the result was discarded. Three additional attempts show no session.started in the trajectory (lock contention). Session remained at overflow ceiling through all six attempts with no successful compaction.
OpenClaw version
2026.6.7-beta.1 (45a103a)
Operating system
macOS 15.5 (Darwin 25.5.0, arm64)
Install method
npm install -g openclaw (Homebrew-managed Node.js v22.22.2, arm64)
Model
anthropic/claude-sonnet-4-6
Provider / routing chain
api-key → anthropic direct (no proxy, no router)
Additional provider/model setup details
agents.defaults.model.primary: anthropic/claude-sonnet-4-6
agents.defaults.compaction.timeoutSeconds: 300 (shipped default: 180)
agents.defaults.compaction.truncateAfterCompaction: true
Auth: GOOGLE_SERVICE_ACCOUNT_KEY env var (unrelated); Anthropic via ANTHROPIC_API_KEY env var, direct HTTP
No per-agent model overrides, no proxy, no fallback chain active during the incident
Logs, screenshots, and evidence
Gateway log — compaction attempts (redacted to relevant lines):
2026-06-17T15:18:15.707-04:00 [agent/embedded] embedded run auto-compaction start (threshold)
2026-06-17T15:19:15.583-04:00 [agent/embedded] embedded run auto-compaction incomplete (threshold)
2026-06-17T15:20:09.xxx-04:00 [agent/embedded] embedded run auto-compaction start (overflow)
2026-06-17T15:21:09.xxx-04:00 [agent/embedded] embedded run auto-compaction incomplete (overflow)
2026-06-17T15:21:42.xxx-04:00 [agent/embedded] embedded run auto-compaction start (overflow)
2026-06-17T15:22:42.xxx-04:00 [agent/embedded] embedded run auto-compaction incomplete (overflow)
2026-06-17T15:23:05.xxx-04:00 [agent/embedded] embedded run auto-compaction start (overflow)
2026-06-17T15:24:05.xxx-04:00 [agent/embedded] embedded run auto-compaction incomplete (overflow)
2026-06-17T15:25:01.xxx-04:00 [agent/embedded] embedded run auto-compaction start (overflow)
2026-06-17T15:26:01.xxx-04:00 [agent/embedded] embedded run auto-compaction incomplete (overflow)
2026-06-17T15:27:08.xxx-04:00 [agent/embedded] embedded run auto-compaction start (overflow)
2026-06-17T15:28:08.xxx-04:00 [agent/embedded] embedded run auto-compaction incomplete (overflow)Every attempt marks incomplete at exactly 60s.
───
Trajectory — compaction sessions (session 91f28c2c):
# Threshold attempt
2026-06-17T19:18:15.655Z session.started
2026-06-17T19:18:15.699Z prompt.submitted
2026-06-17T19:21:09.616Z model.completed aborted=False externalAbort=False timedOut=False
usage: { input: 7, output: 2287, cacheRead: 797548, cacheWrite: 200682 }
2026-06-17T19:21:09.626Z session.ended
-- gateway marked incomplete at 19:19:15.583Z (60s after start) --
# Overflow attempt #1 (15:20:09 EDT / 19:20:09 UTC)
→ NO session.started in trajectory (lock contention; threshold model call still running)
→ gateway incomplete at 19:21:09.583Z — within 33ms of threshold session.ended
# Overflow attempt #2
2026-06-17T19:21:42.xxx Z session.started
2026-06-17T19:21:42.239Z prompt.submitted
2026-06-17T19:24:05.324Z model.completed aborted=False externalAbort=False timedOut=False
2026-06-17T19:24:05.xxx Z session.ended
-- gateway marked incomplete at 19:22:42 (60s after start) --
# Overflow attempt #3 (15:23:05 EDT / 19:23:05 UTC)
→ NO session.started in trajectory (lock contention; #2 model call still running until 19:24:05)
# Overflow attempt #4
2026-06-17T19:25:01.769Z prompt.submitted
2026-06-17T19:28:08.382Z model.completed aborted=False externalAbort=False timedOut=False
-- gateway marked incomplete at 19:26:01 (60s after start) --
# Overflow attempt #5 (15:27:08 EDT / 19:27:08 UTC)
→ NO session.started in trajectory (lock contention; #4 model call still running until 19:28:08)───
Summary table:
| Attempt | prompt.submitted | model.completed | Duration | aborted | Gateway verdict |
| ------------------- | ---------------------- | --------------- | -------- | ------- | ---------------------------------- |
| Threshold | 19:18:15.699Z | 19:21:09.616Z | 174s | False | incomplete @ 60s |
| Overflow #2 | 19:21:42.239Z | 19:24:05.324Z | 143s | False | incomplete @ 60s |
| Overflow #4 | 19:25:01.769Z | 19:28:08.382Z | 187s | False | incomplete @ 60s |
| Overflow #1, #3, #5 | — (no session.started) | — | — | — | incomplete @ 60s (lock contention) |
Impact and severity
Any user whose session reaches ~200K tokens on a model with slow compaction (observed: anthropic/claude-sonnet-4-6). Affects the embedded-agent-runner path — confirmed on Telegram channel; expected to reproduce on any messaging surface using the same runner.
Severity: Blocks workflow. The session becomes permanently stuck at overflow ceiling with no automatic recovery. Every subsequent turn fires a new compaction attempt that fails the same way. The only escape is a manual /new or /compact command — which requires the user to notice the failure, since the session otherwise appears functional (turns continue processing; the compaction failure is silent).
Frequency: Deterministic and always-reproducing once triggered. Any session that reaches ~200K tokens on this model reproduces it on every compaction attempt for the remainder of the session. Not intermittent.
Consequence:
• Session performance degrades progressively as context stays at ceiling
• Every failed compaction attempt submits a full ~200K-context summary call to the provider and discards the result — real API cost burned on each attempt, multiplied across the retry storm (6 attempts observed in a single incident)
• User receives no error or warning; the failure is invisible unless gateway logs are inspected
• Workflow disruption: any long-running task (multi-hour research, forensics, iterative document work) that crosses ~200K tokens is affected
Additional information
Distinction from #92043: #92043 documents EMBEDDED_COMPACTION_TIMEOUT_MS = 180s (the inner model-call safety wrapper in compaction-safety-timeout.ts) killing the model call when the chunk pipeline exceeds 3 minutes. This bug is a different constant at a different layer. The trajectory shows the model call completing at 143–187s with aborted=False — within the 180s inner cap, returning valid output. The 60s outer wait (COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS) in selection-Cy8dzQeR.js abandoned the result before it arrived. #92043's fix does not address this.
Note on symbol lookup: The .js filenames are hashed build artifacts. Grep source by symbol: COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS, waitForCompactionRetryWithAggregateTimeout, DEFAULT_SESSION_WRITE_LOCK_ACQUIRE_TIMEOUT_MS.
Path 1 — Aggregate wait timeout (threshold + even-numbered overflow retries):
checkCompaction fires compact$1 post-turn. The embedded attempt waits in waitForCompactionRetryWithAggregateTimeout with COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS = 6e4 — a local const, not exposed via config. At ~200K tokens the summary takes ~174s; the 60s budget fires first, marks incomplete, exits. The model call continues at the provider, completes with valid output, results discarded.
Path 2 — Lock-acquire contention (odd-numbered overflow retries):
When the 60s wait fires, the abandoned model call keeps running and holds the lock for ~110–130s. The next retry (60s later) finds the lock busy and waits up to DEFAULT_SESSION_WRITE_LOCK_ACQUIRE_TIMEOUT_MS = 6e4 before giving up. Retry interval (60s) < call duration (150–190s) produces alternating success/contention pairs. Confirmed in trajectory: attempts #1, #3, #5 have no session.started; each gave up within ~33ms of the prior call's session.ended. This is downstream of Path 1 — fixing the aggregate wait eliminates the retry storm and the contention with it. See also #88919 (open PR targeting the lock mechanism independently).
Cost impact: Each failed attempt pays for a full ~200K-context compaction call at the provider (aborted=False, confirmed across all three completing attempts). Results discarded each time.
Proposed fix:
agents.defaults.compaction.timeoutSeconds already governs the inner model-call safety wrapper (shipped default 180s; our install: 300s, which covers the 187s observation). The cleanest fix is to wire COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS through that same config rather than adding a new surface — operators who have already raised timeoutSeconds would get the fix for free. On abandon: either wait for the call to complete and consume the result, or cancel it (aborted=True) to avoid paying for a discarded result.
Calibration for #30411: At ~200K tokens, summary calls run 143–187s. Earlier auto-compaction produces a shorter call with more margin against any fixed budget — this data quantifies that relationship.
Related: #92043 (same family, different constant/file — not a dup) · #88919 (lock mechanism, secondary) · #30411 (early compaction threshold, prevention)
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
Both threshold and overflow in-turn compaction paths mark themselves incomplete at 60s and discard a valid compaction result that the provider already returned — the hardcoded COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS = 6e4 outer wait fires before the summary model call finishes (~150–190s on a ~200K-token session), causing the session to drift into overflow and stay there.
Steps to reproduce
Deterministic trigger: any session where the compaction summary model call takes >60s. A ~200K-token session on anthropic/claude-sonnet-4-6 reliably produces call durations of 143–187s and reproduces on every attempt.
Expected behavior
The compaction model call completes with valid output (aborted=False, confirmed by trajectory) — that result should be consumed and the session compacted. Instead, the embedded attempt abandons the wait at 60s and discards the result. Expected: the outer wait either runs to call completion and consumes the result, or cancels the call on abandon (aborted=True) rather than paying for a full provider call and discarding it.
Actual behavior
Gateway logs embedded run auto-compaction incomplete at exactly 60s on every attempt. Trajectory 91f28c2c (June 17, OpenClaw 2026.6.7-beta.1, anthropic/claude-sonnet-4-6) shows prompt.submitted followed by model.completed (aborted=False, externalAbort=False, timedOut=False) at 143s, 174s, and 187s respectively — the call completed successfully at the provider but the result was discarded. Three additional attempts show no session.started in the trajectory (lock contention). Session remained at overflow ceiling through all six attempts with no successful compaction.
OpenClaw version
2026.6.7-beta.1 (45a103a)
Operating system
macOS 15.5 (Darwin 25.5.0, arm64)
Install method
npm install -g openclaw (Homebrew-managed Node.js v22.22.2, arm64)
Model
anthropic/claude-sonnet-4-6
Provider / routing chain
api-key → anthropic direct (no proxy, no router)
Additional provider/model setup details
agents.defaults.model.primary: anthropic/claude-sonnet-4-6
agents.defaults.compaction.timeoutSeconds: 300 (shipped default: 180)
agents.defaults.compaction.truncateAfterCompaction: true
Auth: GOOGLE_SERVICE_ACCOUNT_KEY env var (unrelated); Anthropic via ANTHROPIC_API_KEY env var, direct HTTP
No per-agent model overrides, no proxy, no fallback chain active during the incident
Logs, screenshots, and evidence
Impact and severity
Any user whose session reaches ~200K tokens on a model with slow compaction (observed: anthropic/claude-sonnet-4-6). Affects the embedded-agent-runner path — confirmed on Telegram channel; expected to reproduce on any messaging surface using the same runner.
Severity: Blocks workflow. The session becomes permanently stuck at overflow ceiling with no automatic recovery. Every subsequent turn fires a new compaction attempt that fails the same way. The only escape is a manual /new or /compact command — which requires the user to notice the failure, since the session otherwise appears functional (turns continue processing; the compaction failure is silent).
Frequency: Deterministic and always-reproducing once triggered. Any session that reaches ~200K tokens on this model reproduces it on every compaction attempt for the remainder of the session. Not intermittent.
Consequence:
• Session performance degrades progressively as context stays at ceiling
• Every failed compaction attempt submits a full ~200K-context summary call to the provider and discards the result — real API cost burned on each attempt, multiplied across the retry storm (6 attempts observed in a single incident)
• User receives no error or warning; the failure is invisible unless gateway logs are inspected
• Workflow disruption: any long-running task (multi-hour research, forensics, iterative document work) that crosses ~200K tokens is affected
Additional information
Distinction from #92043: #92043 documents EMBEDDED_COMPACTION_TIMEOUT_MS = 180s (the inner model-call safety wrapper in compaction-safety-timeout.ts) killing the model call when the chunk pipeline exceeds 3 minutes. This bug is a different constant at a different layer. The trajectory shows the model call completing at 143–187s with aborted=False — within the 180s inner cap, returning valid output. The 60s outer wait (COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS) in selection-Cy8dzQeR.js abandoned the result before it arrived. #92043's fix does not address this.
Note on symbol lookup: The .js filenames are hashed build artifacts. Grep source by symbol: COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS, waitForCompactionRetryWithAggregateTimeout, DEFAULT_SESSION_WRITE_LOCK_ACQUIRE_TIMEOUT_MS.
Path 1 — Aggregate wait timeout (threshold + even-numbered overflow retries):
checkCompaction fires compact$1 post-turn. The embedded attempt waits in waitForCompactionRetryWithAggregateTimeout with COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS = 6e4 — a local const, not exposed via config. At ~200K tokens the summary takes ~174s; the 60s budget fires first, marks incomplete, exits. The model call continues at the provider, completes with valid output, results discarded.
Path 2 — Lock-acquire contention (odd-numbered overflow retries):
When the 60s wait fires, the abandoned model call keeps running and holds the lock for ~110–130s. The next retry (60s later) finds the lock busy and waits up to DEFAULT_SESSION_WRITE_LOCK_ACQUIRE_TIMEOUT_MS = 6e4 before giving up. Retry interval (60s) < call duration (150–190s) produces alternating success/contention pairs. Confirmed in trajectory: attempts #1, #3, #5 have no session.started; each gave up within ~33ms of the prior call's session.ended. This is downstream of Path 1 — fixing the aggregate wait eliminates the retry storm and the contention with it. See also #88919 (open PR targeting the lock mechanism independently).
Cost impact: Each failed attempt pays for a full ~200K-context compaction call at the provider (aborted=False, confirmed across all three completing attempts). Results discarded each time.
Proposed fix:
agents.defaults.compaction.timeoutSeconds already governs the inner model-call safety wrapper (shipped default 180s; our install: 300s, which covers the 187s observation). The cleanest fix is to wire COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS through that same config rather than adding a new surface — operators who have already raised timeoutSeconds would get the fix for free. On abandon: either wait for the call to complete and consume the result, or cancel it (aborted=True) to avoid paying for a discarded result.
Calibration for #30411: At ~200K tokens, summary calls run 143–187s. Earlier auto-compaction produces a shorter call with more margin against any fixed budget — this data quantifies that relationship.
Related: #92043 (same family, different constant/file — not a dup) · #88919 (lock mechanism, secondary) · #30411 (early compaction threshold, prevention)