claude-code - 💡(How to fix) Fix Autocompact thrashing: context refills to limit within ~3 turns of compact, repeats [2 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#60600Fetched 2026-05-20 03:54:21
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×3commented ×2closed ×1

Fix Action

Fix / Workaround

Suggested mitigations (user-side workarounds)

But these are workarounds — the underlying loop shouldn't be possible to enter.

RAW_BUFFERClick to expand / collapse

Symptom

Autocompact is thrashing. In a long-running session, the context refilled to the limit within ~3 turns of the previous compact — three cycles in a row.

Each compact appears to do its job (summary produced, prior turns dropped), but the next ~3 tool calls re-bloat the context back to the limit, forcing another compact. Net effect: rapid cycling between compact → 2–3 turns of useful work → compact, with most of the budget spent on summarization rather than progress.

Hypothesis

A file being read or a tool output is likely too large for the context window. After compact, the freshly-loaded tool outputs immediately push back over the threshold.

Likely culprits in my session:

  • MCP tool outputs (Slack channel history dumps, BigQuery result tables)
  • Whole-file reads on large files
  • Possibly outputs that are summarized into the post-compact context but still oversized

Suggested investigation

  • Which tool calls produce the largest payloads post-compact?
  • Are tool outputs being truncated before they're folded into the next context window, or carried in full?
  • Is there a per-tool-output size cap that should kick in earlier (especially for MCP tools that paginate poorly)?

Suggested mitigations (user-side workarounds)

  • Read files in smaller chunks (offset/limit on Read)
  • Use /clear to start fresh when the cycle starts

But these are workarounds — the underlying loop shouldn't be possible to enter.

Environment

  • Claude Code
  • MCP-heavy workflow (multiple Slack MCPs, tool-gateway with BigQuery, etc.)

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 Autocompact thrashing: context refills to limit within ~3 turns of compact, repeats [2 comments, 2 participants]