claude-code - 💡(How to fix) Fix Compaction reports inflated cumulative token count and produces degenerate summary for tool-heavy sessions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
RAW_BUFFERClick to expand / collapse

Problem

The compaction banner reports an inflated, misleading token count ("Compacted from 3,656,675 tokens") that exceeds the model's actual context window (1M tokens) by 3.6x. The number appears to be cumulative session token usage rather than the context size at the time compaction fired.

Additionally, when the conversation is dominated by machine-generated tool calls/results (e.g. from an MCP-heavy agentic workflow), the compaction summarizer produces a degenerate summary: "No task was specified — the conversation is empty" — even when the session has been actively working for hours.

Expected Behavior

  1. The compaction banner should report the actual context window size at the time compaction fires, not cumulative session token usage. If cumulative is shown for informational purposes, it should be labeled as such.

  2. The summarizer should extract meaningful state from tool-call-heavy conversations, or at minimum preserve the most recent assistant reasoning/progress rather than defaulting to "empty."

Reproduction Context

  • Model: claude-opus-4-6 (1M context window)
  • Session type: Long-running agentic session with heavy MCP tool use (GSD workflow automation)
  • Session duration: multi-hour
  • Total units executed: ~1024 over the project lifetime
  • The compaction fires and the summary reads "No task was specified" despite hundreds of completed work units

Impact

  • Users see a number (3.6M) that doesn't correspond to any real limit, creating confusion about what triggered compaction
  • The degenerate summary means the agent loses all context after compaction — it can't continue the task
  • In automated/agentic workflows, this effectively kills the session since the agent has no idea what it was doing

Environment

  • Claude Code (terminal CLI)
  • Model: claude-opus-4-6
  • Platform: Linux

Filed via GSD forensics analysis

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Compaction reports inflated cumulative token count and produces degenerate summary for tool-heavy sessions