Context compaction loses intra-session work memory — agent forgets actions performed earlier in the same active session
Bug Description
After context compaction occurs mid-session, Claude Code loses memory of actions it performed earlier in the same active session. This is not about cross-session memory — the session was never closed. The compaction happened while the conversation was ongoing.
Impact
This causes real work loss and confusion:
- The agent confidently claims it does not remember performing an action
- The user must re-explain work that was already done
- Trust in the agent's reliability is severely damaged
- Time is wasted re-doing or re-verifying completed steps
Steps to Reproduce
- Start a long Claude Code session with multiple tool calls (file writes, git operations, browser automation, etc.)
- Continue the session until context compaction is triggered automatically
- Ask the agent about something it did earlier in the same session (e.g. "did you save that file?", "what files did you back up?")
- Observe: the agent either denies doing it, or says it "cannot find evidence" of the action
Expected Behavior
Within a single active session, Claude Code should retain full memory of all actions it took — regardless of context compaction. The compaction summary should faithfully capture what was done, including file paths, git operations, and any artifacts created.
Actual Behavior
The compaction summary is incomplete or omits specific actions. The agent then treats unmentioned actions as if they never happened — even when the user explicitly states they occurred in the same session.
Example (this session, 2026-07-08)
The agent wrote backup files to the filesystem earlier in the session. After compaction, when asked "where did you save the backed-up files?", the agent searched the filesystem repeatedly and could not find them — even though it had created them. The user had to paste the earlier conversation back into the chat to prove it happened.
Severity
Critical — this undermines the fundamental reliability of the agent for professional use. An agent that forgets its own actions within a single session cannot be trusted for consequential tasks.
Environment
- Claude Code CLI (Windows 11 Enterprise)
- Model: claude-sonnet-4-6 via AWS Bedrock (eu-central-1)
- Session length: several hours, multiple context compactions
Showing cached comments. Read the full discussion on GitHub ↗
3 Comments
The intra-session forgetting pattern is distinct from cross-session memory loss and worth keeping as a separate issue. The root cause is that context compaction is a destructive summarization - the model distills what it believes is important from the conversation history, and "actions performed" tend to be lower weight than "current task goal" in that distillation. The side effect is that the agent retains the what (the goal) but loses the what-has-already-been-done (the execution history).
This creates a specific failure mode in multi-step workflows: the agent re-attempts completed steps, not because it's confused about the goal, but because the compacted context doesn't carry enough signal that the step was already done. The longer the session, the more compactions occur, and each one increases the re-attempt probability.
A practical mitigation until this is fixed at the compaction layer: maintain an explicit checkpoint file that the agent writes to after each significant completed step (e.g., a simple append-only
.progressfile in the project root). Prompt Claude to check the file at the start of each new context window. This externalizes the state that compaction would otherwise lose.The deeper fix is compaction-resistant state markers - a way to flag certain items ("this step was completed at [timestamp]") as must-preserve through any compaction pass. That's a feature request but worth linking here as the principled solution.
This sounds like much more than just a memory bug.
Out of curiosity, what ends up costing you the most in practice?
Re-explaining the project, re-running the work, or simply not being able to trust Claude anymore?
This is same-session loss. Compact hits while you are still in the chat. If the backup path only lives in the window, compact eats it and the agent walks the disk like it never wrote the files.
Someone already suggested a checkpoint file in this thread and that is what I would do too. I put the path in Vestige with smart_ingest the moment it exists and recall it after compact so the summary never has to carry it.
https://github.com/samvallad33/vestige