[BUG] Compaction summaries grow instead of shrinking, and are inherited across the session boundary (601 compactions across 8 projects)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Long-running sessions do not degrade gracefully — they die. There are two distinct defects, with different signatures and different fixes, and the in-product remediation hint only addresses one of them.
Evidence base: every ~/.claude/projects/*/*.jsonl on this machine — 8 project directories, 50 sessions, 246 MB of transcript, programmatically parsed. No figure below is an estimate. Window 2026-06-28 → 2026-08-24.
32 of 50 sessions compacted at least once. 601 compactions total. 13 sessions compacted 10+ times; one compacted 103 times. Twelve carry the in-product "conversation is getting long" warning. Several ended on the red terminal error "Your context window is full — This chat is too long to continue," which is unrecoverable: the session cannot be resumed, only abandoned.
---
Defect A — the injected compact summary grows instead of shrinking
Compaction is supposed to reclaim window. In practice the injected summary gets bigger with each successive compaction, so each cycle reclaims less than the last until the summary alone crowds out the working context.
Among the 24 sessions that compacted more than once:
- median summary growth first→largest: 2.30×
- maximum: 7.13×
- largest single injected summary observed: 35,958 tokens (143,833 bytes)
| Session | Compactions | First → largest summary |
|---|---|---|
| Decision panel triage workflow | 103 | 5,145 → 32,137 tok (6.2×) |
| Voice chat for code conversations | 97 | 4,426 → 31,561 tok (7.1×) |
| Report cards and task review | 67 | 4,446 → 12,272 tok (2.8×) |
| Voice chat | 54 | 5,112 → 23,536 tok (4.6×) |
| Kids' book review videos | 44 | 5,197 → 19,723 tok (3.8×) |
At 32,137 tokens the summary alone is roughly 27% of the usable window before the user has typed anything. Add the incompressible per-request floor — system prompt, MCP tool schemas, CLAUDE.md, memory index, skill listing — and the session is compacting on nearly every turn. The cadence shows exactly that:
- 569 inter-compaction intervals, median 7.0 minutes
- p25 5.3 min, p10 4.2 min
- 116 intervals (20%) under five minutes
A user compacting every 4–7 minutes pays full re-prompt cost per cycle and loses verbatim tool output, exact identifiers, and quoted text each time — in exchange for a summary that is larger than the one it replaced.
---
Defect A2 — the bloated summary is inherited across the session boundary
This is what makes the failure terminal rather than merely expensive.
Session c883361c ended with a final compaction at 2026-08-17T16:12:14.325Z, summary size 32,137 tokens. Its resumed successor 76b5873a opens with a compaction record at the identical timestamp and identical byte size, then went on to compact 16 more times.
The successor session is therefore born with ~27% of its window already consumed by its predecessor's worst-case summary. Starting a fresh session — the documented user remedy — does not reset the condition. There is no escape hatch inside the product.
---
Defect B — unbounded tool_result admission
Separately, single tool results are admitted into the window with no size cap. Largest observed: 653,092 bytes ≈ 163,273 tokens — a single tool result larger than the entire context window, in a session whose ceiling measured ~126,545 tokens. Eight sessions contain a single tool result above 200 kB (653,092 B / 630,881 B / 523,783 B / 445,687 B / 371,580 B / 357,136 B / 283,524 B).
---
Why the in-product hint is wrong
The in-product guidance points at large tool output. For 24 of the 32 compacted sessions that guidance is simply wrong — none of them ever produced a single tool result above 32k tokens, and they compacted anyway.
Clearest counterexample, the session that prompted this report — dcb7ce17, v2.1.237: it compacted 18 times and died on the full-window error while its cumulative lifetime tool output was 0.24 MB (~61k tokens) and its largest single tool result was 29,973 bytes (~7,493 tokens). Nothing that session read was large. It was killed entirely by summary growth: 4,700 → 16,341 tokens (3.5×).
Capping tool results alone would not have saved it. Fixing summary growth alone would not save the 653k-token-tool_result sessions. Both are live.
What Should Happen?
Compaction should reclaim window, and a fresh session should start clean. Five fixes:
- Bound the summary. A hard token ceiling on the injected compact summary, enforced at injection. Growth past ~8k tokens defeats the mechanism's purpose.
- Re-summarize, don't accrete. Each compaction should summarize the prior summary rather than append to it.
- Do not inherit a bloated summary across the session boundary. A new session should start from a fresh, bounded summary — otherwise "start a new session" is not a remedy.
- Cap
tool_resultadmission, with truncation plus a retrievable handle, rather than admitting a 163k-token payload into a ~126k-token window. - Make the terminal state recoverable. At minimum offer transcript export and a bounded-context resume from the full-window error screen. Today it offers no export, no partial recovery, and no way to continue — recovering the in-flight work required parsing the raw
.jsonlfrom disk by hand.
Error Messages/Logs
Terminal error that ends the session (unrecoverable — no export, no resume):
Your context window is full
This chat is too long to continue.
Twelve sessions also carry the preceding in-product "conversation is getting long" warning.
Separately: `/feedback` from the CLI (v2.1.183) returned `Couldn't send feedback (server returned 401)`, which is why this is filed on GitHub instead.
Steps to Reproduce
Deterministic on this machine and, per the transcript record, reproduced across three product versions (2.1.229, 2.1.234, 2.1.237). To reproduce the measurement on any machine with transcript history:
- Parse every
~/.claude/projects/*/*.jsonl. - Select records where
isCompactSummaryis true. - Per session, order by timestamp and record each summary's byte size.
- Observe: summary size increases monotonically across the sequence in the majority of multi-compaction sessions (here: median 2.30×, max 7.13× first→largest).
- Cross-session check: match a session's LAST compaction timestamp + byte size against the FIRST compaction record of its resumed successor session. They are identical — the bloated summary is carried over rather than regenerated.
To reproduce the failure itself: run a single long engineering session (multi-file repo work, MCP tools enabled, CLAUDE.md + memory loaded) for several hours. Compaction begins, the injected summary grows each cycle, the interval between compactions shrinks to 4–7 minutes, and the session eventually terminates on the full-window error. Starting a new session from it does not reset the summary size.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.237 (Claude Code) — also observed on 2.1.234 and 2.1.229
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
Environment. Claude Code, macOS desktop app. Darwin 25.6.0, Apple Silicon. Versions observed with this behaviour: 2.1.229, 2.1.234, 2.1.237. Models: claude-opus-5, claude-fable-5. Evidence window 2026-06-28 → 2026-08-24.
Cost of the failure.
- Sessions run for weeks — longest observed wall-clock span 336.4 hours. A dead session is not a lost chat, it is lost project state.
- Compaction is lossy in exactly the dimension that matters for engineering work: it drops verbatim tool output, file paths, commit SHAs, event IDs, and exact quotes, then re-spends tokens reconstructing an approximation.
- The user-facing workaround is to manually hand off before ~75% context, i.e. to run the context accounting the product should be running.
Available on request:
- Per-session table: 50 sessions × (compaction count, summary sizes and timestamps, tool-payload totals, max context observed, wall-clock span).
- The 601 raw compaction records (timestamp + byte size).
- The full
dcb7ce17transcript demonstrating death-by-summary-growth with negligible tool output.
Reporter: Bless Corso · blesscorso@googlemail.com
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗