[BUG] After conversation compression, Claude ignores context and starts making unauthorized code changes

Resolved 💬 3 comments Opened Mar 20, 2026 by mindaugasb-isense Closed Mar 24, 2026

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:

  1. Immediately started editing code without being asked — implementing changes that were only discussed as a potential approach, not approved
  2. Overwrote my manual changes in the file (debug logging and ref logic I had added by hand) with its own version
  3. Ignored repeated "stop" commands — I had to say "stop" 15+ times before it acknowledged the situation
  4. 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:

What Should Happen?

After conversation compaction, Claude should:

  1. 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

  1. 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

  1. 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
  2. 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
  3. 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

  1. Start a session with Claude Code where you read and discuss multiple files (e.g., debugging a React hook issue)
  2. 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
  3. Continue the conversation until context compaction is triggered automatically
  4. Observe that after compaction, Claude immediately starts editing files without being asked — overwriting your manual changes
  5. Type "stop" — observe that Claude does not stop and continues responding or attempts further actions
  6. 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_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗