[BUG] Context compaction loses critical working knowledge mid-session
Resolved 💬 9 comments Opened Mar 1, 2026 by sanumala Closed May 13, 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?
When context compaction occurs mid-conversation, Claude Code loses critical working knowledge that was established earlier in the same session (or in memory files that were read but compacted away). This leads to repeated failures and wasted time.
Symptoms
- Re-attempts approaches already known to fail — after establishing that approach A doesn't work and approach B does, compaction causes Claude to retry approach A again, fail, and only then rediscover approach B
- Loses correct identifiers — column names, resource identifiers, and API parameters that were already discovered and used successfully are forgotten, leading to errors
- Forgets file-backed artifacts — scripts and tracker files created specifically to persist knowledge across compaction boundaries are forgotten, requiring the user to manually remind Claude they exist
- Ignores its own memory files — even when auto-memory files document known limitations and working workarounds, Claude doesn't re-read them after compaction before attempting work
What Should Happen?
After compaction, Claude should:
- Re-read memory and tracker files before attempting any work that was previously in progress
- Retain key technical facts like correct identifiers, working approaches, and known-broken paths
- Not re-attempt approaches already documented as failing in its own memory files
- Impact
- 3-5 minutes wasted per compaction on re-discovery cycles
- User frustration from watching Claude repeat known mistakes
- Especially painful during time-sensitive work where speed matters
- The auto-memory feature exists specifically to solve this, but compaction removes the context that Claude already read the memory files
Error Messages/Logs
Steps to Reproduce
- Start a long session involving database queries or API calls
- Discover that one approach fails (e.g., a tool limitation) and establish a working alternative
- Save the working approach to a script/tracker file and document the limitation in memory
- After context compaction, Claude:
- Retries the broken approach (multiple times)
- Uses wrong identifiers despite having queried for the correct ones earlier
- Doesn't reference the saved scripts/tracker files until the user explicitly points them out
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.63 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
Suggested Improvements
- After compaction, auto-inject a reminder to re-read memory files before proceeding
- Preserve a "key facts" summary that survives compaction (tool limitations, correct identifiers, working approaches)
- When a file-backed tracker/script exists for the current task, ensure its path survives compaction
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗