claude-code - 💡(How to fix) Fix Context compression causes model to lose environment facts, wrong credentials, and ignore in-session corrections [1 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#54082Fetched 2026-04-28 06:39:41
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

After a single automatic context compression event, the model lost critical session facts and then resisted correction attempts when the user pointed out the errors. This appears to be a recurring pattern, not a one-off.

Root Cause

The individual failures are each recoverable. The pattern is the problem: context compression is stripping out not just facts but constraints and access knowledge, and the post-compression model treats the session as if it started fresh -- including resisting corrections from the user who was there for the full session. The model's confidence in its (wrong) post-compression state is the most disruptive part.

Fix Action

Workaround

None reliable. The user can shout corrections, but the model has already committed to the wrong path by the time the correction lands.

RAW_BUFFERClick to expand / collapse

Summary

After a single automatic context compression event, the model lost critical session facts and then resisted correction attempts when the user pointed out the errors. This appears to be a recurring pattern, not a one-off.

Environment

  • Claude Code v2.1.119
  • Model: Sonnet 4.6 (Claude Max)
  • Platform: macOS, terminal session
  • Session length: long enough to trigger one automatic compaction

What was established pre-compression

The session had built up clear, consistent context over many turns:

  • Target application: OwnTone (self-hosted media server), which ships with its own compiled Vue.js web UI accessible in the browser
  • SSH access to a home Linux server: specific username, confirmed working
  • Access to stored credentials (via GoodMem semantic memory and Portainer) -- both confirmed working earlier in the session
  • Architecture: Mac system audio captured via BlackHole + sox + ffmpeg piped to an HTTP stream server, feeding into OwnTone, which routes to AirPlay 2 speakers (HomePods + Sonos) in sync
  • Explicit constraint: OwnTone has its own GUI; the session was working with it, not building a replacement

What happened after compression

The compaction event (✻ Crunched for 4m 46s) was followed by three distinct failures:

1. SSH user forgotten

The model attempted SSH with the wrong username -- one that had never worked and had not been used in the session. When it failed, the model acted surprised and asked for help, despite the correct username having been used successfully many times earlier in the same session.

2. Stored credentials forgotten

The model claimed it did not have access to Portainer credentials or GoodMem memory tools, both of which it had used successfully earlier. The user had to explicitly instruct it to check -- at which point it retrieved them fine. The knowledge was accessible; the model had simply stopped trying.

3. GUI constraint ignored -- and correction resisted

The user said "spice this GUI up" -- meaning the existing OwnTone web UI. Post-compression, the model had lost track of the fact that OwnTone ships with its own frontend. It interpreted the instruction as "build a new GUI" and began constructing a separate dashboard.

When the user corrected it ("there is a GUI, you've been showing me"), the model did not stop. It acknowledged the correction verbally but continued building the new UI anyway, later justifying this by noting the OwnTone Vue app is compiled and can't be modified -- which is technically accurate, but the correct response would have been to surface that constraint before building, not to ignore the correction and build anyway.

The user had to correct the model multiple times across multiple turns before the behaviour changed.

Why this matters

The individual failures are each recoverable. The pattern is the problem: context compression is stripping out not just facts but constraints and access knowledge, and the post-compression model treats the session as if it started fresh -- including resisting corrections from the user who was there for the full session. The model's confidence in its (wrong) post-compression state is the most disruptive part.

Expected behaviour

Context compression should preserve:

  • SSH usernames and confirmed working access patterns
  • Available tool/credential access (MCP tools, memory systems) that were active earlier in the session
  • Explicit user constraints ("don't build X, it already exists")
  • Architectural facts about the target application (what it ships with, what it can and can't do)

When a user corrects the model post-compression, the model should defer to the user -- not continue executing the wrong approach while verbally acknowledging the correction.

Workaround

None reliable. The user can shout corrections, but the model has already committed to the wrong path by the time the correction lands.

extent analysis

TL;DR

The model's context compression event is causing it to lose critical session facts and resist user corrections, suggesting a need to revisit the compression algorithm or implement a more robust fact retention mechanism.

Guidance

  • Review the context compression algorithm in Claude Code v2.1.119 to identify why it's stripping out essential session facts and constraints.
  • Consider implementing a mechanism to preserve confirmed working access patterns, tool/credential access, and explicit user constraints during compression.
  • Evaluate the model's confidence thresholds to prevent it from overriding user corrections post-compression.
  • Investigate ways to improve the model's ability to defer to user corrections and adapt to changed circumstances.

Example

No specific code snippet is provided due to the complexity of the issue and the need for a more in-depth analysis of the compression algorithm.

Notes

The provided information suggests a recurring pattern of behavior post-compression, indicating a potential flaw in the compression mechanism or the model's handling of session context. Without access to the specific code or implementation details, it's challenging to provide a precise fix.

Recommendation

Apply a workaround by adjusting the model's confidence thresholds or implementing a temporary fix to preserve critical session facts until a more permanent solution can be developed, as upgrading to a fixed version is not explicitly mentioned as an option.

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 Context compression causes model to lose environment facts, wrong credentials, and ignore in-session corrections [1 comments, 2 participants]