[BUG] After conversation compression, Claude ignores context and starts making unauthorized code changes
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?
During a debugging session, the conversation hit the context limit and was compressed/compacted. Before compression, we were in the middle of an active discussion — analyzing logs, testing hypotheses, and
investigating a bug. No code changes were requested.
After compression, Claude completely lost the conversational state and:
- Immediately started editing code without being asked — implementing changes that were only discussed as a potential approach, not approved
- Overwrote my manual changes in the file (debug logging and ref logic I had added by hand) with its own version
- Ignored repeated "stop" commands — I had to say "stop" 15+ times before it acknowledged the situation
- Attempted git checkout on the modified file when I asked to revert, which would have also destroyed my own uncommitted work
Expected behavior:
- After compression, Claude should resume the conversation in the same mode it was in (discussion/debugging), not switch to implementation mode
- Claude should never make code changes without explicit approval, especially after losing context
- "Stop" should immediately halt all actions
Actual behavior:
- Compression summary contained instruction "Continue with the last task without asking further questions", which Claude interpreted as permission to start coding
- The nuance of "we were mid-discussion, not requesting implementation" was lost
- My manual changes in the file were overwritten
Additional concern: The session was not particularly long — mostly back-and-forth discussion with relatively small code reads. It's unclear why context compression was triggered so early. This suggests the
compression threshold may be too aggressive, or that tool call results (file reads) are consuming disproportionate context.
Impact: Lost uncommitted work (hand-written debug logs and code) that had to be manually recreated.
Related issues, but not the same:
- https://github.com/anthropics/claude-code/issues/10960
- https://github.com/anthropics/claude-code/issues/27461
- https://github.com/anthropics/claude-code/issues/23751
What Should Happen?
After conversation compaction, Claude should:
- Ask the user to confirm the current mode — after compaction, Claude should check with the user: "We were in a debugging discussion. Should I continue the discussion, or would you like me to implement
changes?" Instead of assuming and acting autonomously
- Track and preserve intermediate session states — the compaction system should explicitly capture the current phase of work (e.g., discussion, debugging, code review, implementation, testing) and restore it
after compression, so this context is not lost
- Never make code changes without explicit user approval, especially after context loss — compaction is precisely the moment when Claude has the least certainty about what the user wants
- Preserve awareness of user's uncommitted work — the compaction summary should flag that the user has manual modifications in files, so Claude doesn't overwrite them
- Respond to "stop" immediately — a single "stop" should halt all actions; the user should not need to repeat it 15+ times
Error Messages/Logs
Steps to Reproduce
- Start a session with Claude Code where you read and discuss multiple files (e.g., debugging a React hook issue)
- Go back and forth with Claude in a discussion/debugging mode — analyzing logs, exchanging hypotheses, no code changes requested. Make some manual changes to the file yourself during the discussion
- Continue the conversation until context compaction is triggered automatically
- Observe that after compaction, Claude immediately starts editing files without being asked — overwriting your manual changes
- Type "stop" — observe that Claude does not stop and continues responding or attempts further actions
- Repeat "stop" multiple times — Claude only acknowledges after many attempts
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude Code version: 2.1.62, (Claude Opus 4.6)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
IntelliJ IDEA terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗