Claude Code auto compact: what survives the summary

Claude Code auto compact folds old messages into a summary when the conversation approaches the model's context window, so a full window does not end your session. It is on by default. What happens when the Claude Code context window is full is therefore not an error but a rewrite: the conversation becomes a summary, while files the client trusts are re-read from disk. This post covers when the pass runs, what survives it, how to direct it, and what we measured across nine compactions in one benchmark.

When auto compact runs

The setting is autoCompactEnabled, default true, shown as Auto-compact in /config. The context window documentation describes the trigger: Claude Code compacts automatically as you approach the limit. Three controls change the moment:

  • /context shows current context usage, including the warning when the conversation has grown past the window:Context exceeds the 200k-token limit by 94k tokens — run /compact or /clear to continue. With auto-compact on, you can just send your next message.
  • /autocompact with a token count, such as/autocompact 500k , sets how full the window gets before the automatic pass runs — the auto compact threshold, in other words.
  • DISABLE_AUTO_COMPACT turns the pass off for one session. With it off, messages past the limit fail withContext limit reached until you run/compact or/clear yourself.

On 1M-context models a separate compaction window can sit below the model's window — the 200K boundary — so the warning can name a compaction window rather than the model's full context window size. A conversation left idle can also compact on its own; the settings reference has the idle threshold.

What survives the summary

Compaction summarizes the conversation history. It does not delete the mechanisms that load from disk. The documentation lists what happens to each:

| Mechanism | After compaction | |---|---| | System prompt and output style | Still apply | | Project-root CLAUDE.md and unscoped rules | Re-injected from disk | | Auto memory | Re-injected from disk | | The plan written in plan mode | Re-injected from disk | | Files Claude read or edited | Up to five re-read, most recently modified first | | Invoked skill bodies | Re-injected, capped at 5,000 tokens per skill and 25,000 total | | Nested CLAUDE.md and path-scoped rules | Reloaded on demand | | Conversation history | Summarized |

The practical reading: anything you wrote in a file comes back verbatim, and anything that only exists in the conversation comes back as the summary's version of it. A rule you stated in chat ten requests ago is in the summary's hands. A rule in CLAUDE.md is not.

Directing the summary

Three commands give you a say in what the summary keeps, the core of Claude Code context management:

  • /compact with instructions:/compact focus on the auth bug fix . The summary keeps what you choose instead of what the automatic pass guesses is important. Run it before starting a long new task, not after the window is full.
  • /rewind , thenSummarize from here orSummarize up to here : compact part of the conversation and keep the rest intact.
  • /clear starts a new session with an empty conversation. The earlier session is preserved and can be resumed, so clearing context is not deleting it.

What we measured

Besydr (say: besider) is a program that supervises a coding agent and learns from its sessions. In our Claude Code benchmark, the long-sessions scenario worked on pytest in two sessions of 18 and 16 requests, and the conversation was compacted into a summary nine times. We counted how often a rule stated ten or more requests earlier was broken:

| Setup | Rules broken | |---|---| | Claude Code alone | 0 of 96 chances | | Claude Code with Besydr | 0 in the same scenario |

This is a null result, and it is the point. Inside one session, Claude Code keeps the rules of that session through each compaction by itself; repeating them with every prompt, as Besydr does, added nothing here. The decay we measured lives elsewhere: across sessions and projects, where rules from an earlier session were broken 47 times per 100 requests without Besydr and 4 with it. If your agent forgets a rule, check first whether the rule ever left the conversation it was stated in.

What a summary can still lose

The null result covers stated rules, not everything. A compaction folds much of what it touches into prose, and most of that is tool results: the output of commands and file reads the agent ran earlier. A summary that drops an error message or a path the remaining work depends on costs a re-run later.

Since version 0.4.0, Besydr guides this step on Claude Code (the main session only, not subagents) and OpenCode: before the client compacts, Besydr's decision model — the model Besydr calls for its own judgments — marks which earlier tool results the current task still needs, and the client gets instructions to keep their details — names, paths, error text, numbers — and drop the rest. It costs one extra decision-model call per compaction and fails open: if the model is slow or unreachable, the client compacts as it would have. The release post has the settings and limits. The local program is free with octomind and needs a licence with Claude Code after a trial.

Sources and method

原文来源:besydr.com