claude-code - 💡(How to fix) Fix C:/Program Files/Git/compact leaves session in inconsistent state when it fails mid-execution (e.g. rate limit) [2 comments, 3 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#60542Fetched 2026-05-20 03:55:52
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

When /compact fails partway through (in my case, hitting a usage limit during compaction), the session resumes in a chaotic half-compacted state instead of cleanly rolling back or completing. The next turn sees a flood of replayed <system-reminder> blocks for tool calls from before compaction, the post-compaction summary, and any new user messages, all at once — and the agent has no coherent way to interpret them.

Error Message

  1. Have compaction fail — easiest way is to be near a usage limit so the compaction call itself errors out (Error during compaction: You've hit your limit · resets ...).

Root Cause

For long-running engineering sessions, /compact is the main tool to keep going past context limits. If it can leave the session in a broken state, users either lose their place or have to /clear and rebuild context from persisted files — which defeats the point.

RAW_BUFFERClick to expand / collapse

Summary

When /compact fails partway through (in my case, hitting a usage limit during compaction), the session resumes in a chaotic half-compacted state instead of cleanly rolling back or completing. The next turn sees a flood of replayed <system-reminder> blocks for tool calls from before compaction, the post-compaction summary, and any new user messages, all at once — and the agent has no coherent way to interpret them.

Repro

  1. Have a long session with several recent tool calls (Reads, Edits, etc.).
  2. Run /compact.
  3. Have compaction fail — easiest way is to be near a usage limit so the compaction call itself errors out (Error during compaction: You've hit your limit · resets ...).
  4. Wait for limit to reset, send another message, or run /compact again.

Observed

The next assistant turn receives:

  • The conversation summary from the (eventually-successful) second compaction.
  • A series of <system-reminder> blocks replaying tool calls and their results from before the first failed compaction (Read results, plan-mode contents, etc.) — as if those tool calls just happened in the current turn.
  • A <local-command-stderr> for the failed /compact.
  • A <local-command-stdout> for the successful one.
  • The deferred-tools notice listing tools whose schemas now need re-fetching.

The agent essentially gets four overlapping "here's your current state" signals and has to guess which one is authoritative. In practice it behaves erratically — re-reading files it doesn't need to, treating stale tool results as fresh, or skipping the actual user task.

Expected

/compact should be atomic:

  • Success path: next turn starts from the compacted summary only, with no replayed pre-compact tool reminders.
  • Failure path: session stays exactly where it was before /compact ran — no partial summary, no replayed reminders, no half-applied state. User can retry once the underlying issue (rate limit, network, etc.) clears.

Environment

  • Claude Code CLI on Windows 11
  • Model: Opus 4.7
  • Rate limit hit was an Anthropic plan limit, not network

Why this matters

For long-running engineering sessions, /compact is the main tool to keep going past context limits. If it can leave the session in a broken state, users either lose their place or have to /clear and rebuild context from persisted files — which defeats the point.

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