Auto-compact fails repeatedly, blocks long sessions with substantial in-context state
Summary
Auto-compact has failed three times in two days across multiple concurrent Claude Code sessions, leaving sessions in a retry loop that blocks productive work. The failures consistently affect long sessions with substantial in-context state (research work, multi-file code edits).
Environment
- Claude Code version: v2.1.148 (npm install -g @anthropic-ai/claude-code, installed today)
- Model: Opus 4.7 (1M context) —
claude-opus-4-7[1m] - OS: macOS Darwin 24.2.0 (Apple Silicon)
- Install path:
/opt/homebrew/bin/claude(npm, not Homebrew-managed)
Pattern
Across three incidents on 2026-05-22 and 2026-05-23:
- Long-running session accumulates substantial context (research sweeps producing per-cell results in-context, or multi-file code edits across a substantive feature).
- Auto-compact triggers as expected when approaching context limits.
- Compact fails — session does not summarize successfully.
- Retry loop — the failure itself produces context that triggers more compact attempts. Session becomes unusable.
- Forced restart — only resolution is killing the session and reloading from on-disk state (git, persisted files).
Impact
- Incident 1 (2026-05-22): Research session lost ~45 minutes of compute time after auto-compact wiped in-progress sweep results that hadn't been persisted to disk. Recovery required re-running the entire sweep.
- Incident 2 (2026-05-23, this morning): Code-edit session hit compact retry loop mid-PR-wrap-up. Session became unresponsive. Restart required.
- Incident 3 (2026-05-23, afternoon): Two concurrent sessions hit the same failure simultaneously. Both required restart. Mid-session work was at risk for both.
The failures aren't single-session bugs — they're a recurring pattern affecting multiple distinct sessions across different workflows (research, build, review).
What we'd find useful
- Diagnostic info captured during compact failures so we can report specifics (currently the failure surfaces as a generic retry without a copyable error message)
- A graceful degradation path when compact fails — ideally a user-visible message + offer to write context to disk for manual recovery, rather than a silent retry loop
- Visibility into compact behavior with the 1M context window specifically — multiple sessions concurrently using
claude-opus-4-7[1m]may be hitting an edge case the standard context window doesn't surface
Workaround in place
We've adopted aggressive on-disk persistence discipline — every long-running session writes intermediate results to disk continuously so session loss doesn't equal work loss. This mitigates the impact but doesn't address the root cause. The retry-loop behavior specifically remains painful regardless of whether work is saved.
Reproduction notes (best we can describe without error messages)
Not reliably reproducible on demand, but consistent shape:
- Session running for several hours
- Substantial in-context state (>500k tokens estimated)
- Multiple concurrent sessions on same machine
- Triggers when context approaches limits
Happy to provide more detail if Anthropic engineers can suggest what telemetry or logs would help diagnose. Currently we don't see a way to capture the failure beyond observing the retry loop behavior.
Thanks.
— Jeff Auston
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗