Skip to main content

Guides

Claude Code Auto-Compact: Why the Summary Loses Your Work

Claude Code auto-compact context loss and session continuity

You spent two hours grinding through a refactor. Claude Code had the architecture in its head, the test failures memorized, and a TodoWrite list ten items deep. Then the auto-compact banner appeared, the session paused, and when it resumed the agent had become helpful in a strangely generic way. It forgot the decision about the cache layer. It re-asked a question you had already answered. The work is technically still going. The continuity is gone.

What auto-compact actually does

Claude Code maintains a context window per session. As the conversation grows, every new turn replays the prior turns in full — tool calls, tool results, your messages, the agent's responses. The context window has a hard ceiling. When the running token count crosses roughly 95 percent of that ceiling, auto-compact fires.

Anthropic's published documentation describes the mechanism in plain terms: Claude Code clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. The summary replaces the prior turns. The session continues from the summary plus whatever recent turns survived the cut.

The intent is honest. Sessions hit the ceiling all the time, and the alternatives are worse: crash, refuse new turns, or force a full restart. Auto-compact lets the conversation keep moving. The cost of that movement is the summary itself.

Why the summary degrades the work

The summary is generated by a model call. It is not free. It pays out of the same context window it is trying to compress. And it is making choices about what to keep and what to drop — choices it cannot verify, because the only source of truth about what mattered is the conversation it is currently summarizing.

A few specific patterns make the degradation visible:

  1. Tool-call results disappear first. The "older tool outputs first" rule means that the file you read on turn three, the test failures from turn seven, and the grep results from turn twelve are the earliest things to go. The agent's later reasoning referenced those results. After compact, the reasoning survives but its evidence does not.
  2. Decisions become assertions. A multi-turn debate about whether to use a Service class or a Helper becomes a one-line summary that says "decided to use a Service." The reasoning that produced the decision — the constraints, the trade-offs, the precedent in the codebase — collapses. When the next turn raises a related question, the agent has only the conclusion to work from.
  3. Long-tail rules get dropped. Project-specific constraints that came in early ("never Block here, always do Block there") survive only if the agent referenced them recently. A rule established on turn five and not invoked until turn forty does not always make the summary cut.
  4. Identity drifts. The summary uses neutral phrasing. After compact, the agent's "voice" shifts toward generic competent-assistant. The local idioms — the codebase's naming, the project's vocabulary, the user's preferred way of being addressed — get smoothed out.

The canonical quote from the community captures the failure mode in one phrase, repeated across GitHub issue #13112 and dozens of Reddit threads:

summary of a summary of a summary

A session that crosses two or three compact boundaries is summarizing summaries by the end. The information loss compounds. The agent's helpfulness becomes asymptotically generic.

When compact arrives matters more than how often

The 95-percent threshold sounds well-engineered. It is also the worst possible moment for the compact to fire, because the agent is at the densest point of its current task when the threshold is crossed. The work that is most expensive to lose is the work loaded immediately before the summary writes.

A worked example. The agent has been debugging an N+1 query for forty minutes. It has read the Repository class, traced the auto-update chain, identified two suspect joins, and is on the brink of a fix. The context fills to 95 percent because the joined SQL output in turn thirty-two was huge. Auto-compact fires. The summary preserves "user is debugging N+1; agent identified two suspect joins." It drops the actual SQL output, the trace, and the half-formed hypothesis about which join is hot.

Post-compact, the agent reads the file again. It re-traces the chain. It re-asks which of the two joins to focus on. The clock on the fix resets. The user, who is the one paying attention through all of this, watches the agent start over and feels their grip on the task slip.

This is not a failure of the compact algorithm. It is the geometry of the threshold: the densest moment of the session is the moment compact most aggressively rewrites it.

What developers reach for first

The community workarounds, in order of how often they appear in threads:

  1. Run /compact manually at a clean stopping point. Anthropic's own recommendation. Trigger the summary when you have just finished a sub-task, the agent's working memory is light, and the loss is bounded. Works when you remember. The threshold does not wait for the user to remember.
  2. Put persistent rules in CLAUDE.md or AGENTS.md. These files reload on every turn, so they survive compact by definition. Good for project conventions. Not a substitute for in-session memory — the decisions made during the current task do not belong in a tracked file.
  3. Use subagents for isolation. Spawn a sub-task as an agent, let it work in its own window, and have it return a summary you control. The parent session gets one line of work product instead of forty turns of trace. This is Anthropic's recommended pattern and it does work for clearly bounded sub-tasks. It does not help when the work is one continuous thread.
  4. Take screenshots of decisions and feed them back. A community hack that surfaces on most threads: when the agent makes a decision worth keeping, ask it to write the decision to a markdown file with full reasoning, then read that file back after compact. Slow. Lossy. Better than nothing.
  5. Restart the session and replay. The nuclear option. Open a new session, paste the most recent state into the first message, hope the agent picks up. Loses every micro-decision the prior session made. Discards the TodoWrite list. Discards the trace.

The shared trait of all five is that they pay the cost of compact in human attention. The user is the one remembering to manage context. The user is the one curating what to keep. The user is the one paying the time bill for the agent's forgetting.

What a session-continuity layer changes

The structural fix is to snapshot session state before compact fires, externally to the conversation, and to make that snapshot a first-class artifact the user can return to.

A working continuity layer:

  • Watches the context counter and snapshots at 85 percent, not 95. The earlier write captures the dense state of the session before the threshold-forced summary degrades it. The snapshot is JSONL: every turn, every tool call, every result, verbatim. See how the watchdog snapshots, then install Power Claude Free to run it today — no credit card — or start a 14-day Premium Trial for $0 today, cancel anytime before day 15.
  • Persists the TodoWrite list separately. The list is the agent's working plan. It is the thing most worth preserving across compacts and across crashes. A continuity layer writes it to disk every time it changes, not just at compact time.
  • Provides a resume command. After a compact (or a crash, or a restart) the user can resume the session against the latest snapshot. The replay is bounded: a configurable window of recent turns plus the full TodoWrite list, fed back into a fresh context. The agent picks up where it was, with the decisions intact, not a summary of them.
  • Logs every decision worth keeping. When the agent commits to a non-obvious choice ("using a Service because the Helper would have a database dependency"), the continuity layer surfaces it for the user to confirm and store. The store is searchable, separate from the conversation, and survives every compact the session ever hits.

This does not change how compact behaves. Anthropic's logic still runs. The threshold still fires at 95 percent. The summary still gets written. The difference is that the user is not relying on the summary as the authoritative record of what happened. The snapshot is the record. The summary is what the live conversation can fit.

The boundary is honest: Claude Code's published architecture is the source of truth about what compact does in the live session. A continuity layer is the source of truth about what happened before the summary touched it.

Frequently asked questions

Can I disable auto-compact entirely?

No, and you would not want to. The threshold is what keeps the session from hitting a hard refusal. Without compact, a long session terminates the next turn after it crosses the cap. The right configuration is to compact early (manual /compact at clean checkpoints) and to externally snapshot state so the auto-compact you do hit is less expensive.

Why does the agent re-ask questions I already answered after auto-compact?

Because the questions and the answers were both in the part of the conversation the summary dropped or compressed. The agent's post-compact state is what the summary chose to retain. Anything the summary deemed less important — including question-answer pairs that did not produce a code change — is gone. The fix is to make those answers durable outside the conversation: write them to a project file, log them in a continuity store, or hand them back to the agent at the start of the next turn.

How big a summary does auto-compact produce?

Anthropic's documentation does not commit to a fixed size, but observed behavior puts the summary in the 2K-to-8K token range — small enough to leave headroom for new work, large enough to retain the agent's high-level grasp of what it was doing. The smaller the summary, the more the session "feels" generic afterward. The larger the summary, the less headroom you bought back.

Will adding more to `CLAUDE.md` reduce the compact damage?

It depends on what you add. Persistent project conventions, naming rules, and architectural constraints belong there and are reloaded fresh on every turn, so they survive any number of compacts. In-session decisions ("we are using the Service for this specific task") do not belong there — CLAUDE.md would bloat without bound. A continuity layer is the correct home for that kind of decision.

Does the same auto-compact threshold apply to subagents?

Yes. Subagents have their own context windows and their own 95-percent threshold. A long-running subagent can compact itself mid-task. The parent session does not observe the compact directly — it only sees the final return value the subagent produces. This is why Anthropic recommends keeping subagents bounded to a single sub-task: a deep subagent can summarize away its own work just as easily as the parent session can.

Related reading

What developers are reporting

The compaction-amnesia pattern is well documented. GitHub issue #23620 describes an agent team that "completely loses awareness of the team" after compaction — "the team effectively vanishes mid-session" — and #46086 calls out the slower "semantic erosion" where firm rules soften into vague preferences over successive summaries.

Closing

The 95-percent threshold is not going away. The summary is the price of running long sessions, and the price is paid in the densest part of the work. The fix is not to fight the compact — it is to make sure the record of the work survives the compact, externally, in a form the user controls. The session-continuity layer we ship is the version we wrote for our own long-running refactors, and the version that turned "summary of a summary" from a recurring grievance into a configuration choice.

If you want to keep a session's state across your own next compact, the 14-day Premium Trial is $0 today and you can cancel anytime before day 15 — it adds the watchdog snapshots, the resume command, and the decision log on top of rotation. Not ready to add a card? Install Power Claude Free instead — the 7-day free trial gives you full Pro access, no credit card.