Skip to content
Mastering Claude

Home / Context and cost

Context and cost7 minApplication

The auto-compact threshold does not do what you think

The auto-compact threshold triggers a summary of the conversation when the context reaches it, it is not a wall that closes the window: a value set above the real window of the active model is capped at that window, a documented behaviour whose lack of an on-screen warning still needs to be checked for yourself.

The auto-compact threshold is not a fence that would stop the context from exceeding a given size. It is a trigger point: when the conversation reaches this threshold, Claude Code launches an automatic summary of the history. Nothing in this mechanism closes the window itself, and a threshold value set above the real window of the active model produces no displayed error: it is simply capped at that window.

The cap, with no guaranteed warning

The official documentation states it plainly: the limit that applies is always the model's own, whatever the threshold value configured elsewhere. Setting a threshold to one million tokens while the active model only has a window of two hundred thousand tokens pushes nothing back, the calculation falls back to the real two hundred thousand tokens. The documentation does not explicitly say whether this capping comes with an on-screen warning or not, it only documents the capping itself: checking it on your own machine is worth more than assuming it is silent.

When the summary loops on itself

A second mechanism complicates the picture. After a compaction, if the context fills up again to the limit almost immediately, and this cycle repeats several times in a row, Claude Code stops relaunching compaction and displays an explicit error rather than continuing to loop.

Autocompact is thrashing: the context refilled to the limit...

This opening line, which the documentation itself quotes before cutting off with an ellipsis, signals an anti-thrashing guard, a mechanism that recognises that one summary after another solves nothing as long as the source of the filling, a large file reread on every tool call for example, remains in the conversation. The guard stops after a few attempts and surfaces this error rather than continuing to loop silently.

A compaction you did not start

Since October, a long conversation left idle in the terminal can be compacted shortly before the one hour cache expires, so that the next message does not reprocess the whole conversation. The documentation page on the cache says so and gives the idleCompaction setting to turn it off, and the notices shown after such a compaction say how. A discomfort felt as "the context window" can therefore be this compaction: note each time whether it was manual, at saturation or at rest before touching a threshold. The figure gives the delay and the size taken from the changelog.

Two other changes concern the threshold itself. The /autocompact setting is saved per model, so each model keeps its own when you switch. The CLAUDE_CODE_AUTO_COMPACT_WINDOW variable accepts the k and M suffixes: the value 200k used to silently set a window half the size, and the variable now warns about a value that is out of range or ignored.

What to do about it

First, a custom threshold set higher than the model's window is useless, you need to check the real window of the current model before configuring anything. Second, a session that displays a thrashing error signals a content problem, not a software fault: the right move is to remove what is filling the context rather than relaunching the same action hoping for a different result. The neighbouring lesson on compacting, clearing, reading only what is needed details how to choose between these two commands once this threshold is understood.

Figure 1

The threshold against the model's real window

What people think

The auto-compact threshold closes the context window at the configured value, like a hard cap that would block any overrun.

What is measured

A threshold value set above the real window of the active model is capped at that window, without the documentation specifying whether a message accompanies this capping.

The left column shows the intuitive expectation of a hard cap, the right column shows the behaviour actually documented when the threshold exceeds the active model's window.
Figure 2

Idle compaction in two figures

54minutes
of idleness, about, before idle compaction, that is before the one hour cache expires
github.com/anthropics/claude-code (CHANGELOG.md), 2026-10-24
200Ktokens minimum
minimum size of the conversation concerned, adjustable through the CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS variable
github.com/anthropics/claude-code (CHANGELOG.md), 2026-10-24
The first figure gives the idle delay, the second the minimum size of the conversation concerned.
Calibrate it yourself

An association configures the auto-compact threshold of its Claude Code session to a value well above the real window of the model it is using that day. It then carries on a long documentary research conversation for several hours.

Write in one sentence what this situation establishes, and in one sentence what it does not establish.

What to remember
  • The auto-compact threshold works as a summary trigger, never as a fence that would stop the context from growing further.
  • A threshold value set above the real window of a model is capped at that window; whether this capping comes with an on-screen message or not still needs to be checked for yourself, the documentation does not specify it.
  • An anti-thrashing guard stops repeated compaction attempts when the context fills up again right after each summary, and it displays an error rather than continuing to loop.
  • The real window of the active model remains the only limit that counts, a custom setting can never widen it.
  • A long conversation left idle can be compacted at rest before the cache expires, and the idleCompaction setting turns it off.
Do this now

Open an active Claude Code session, type /model to read the real window shown for the current model, then type /context to see how much of that window is already used. Note both figures: it is this real window, never a higher custom threshold, that sets the true limit of your session.

What still needs checking

These points depend on an interface or a rule that may have changed since this was written. Check them on your own screen before relying on them.

  • The default value of the auto-compact threshold shown on your own Claude Code installation: it can vary by model and installed version, read it directly via /context rather than off a figure announced here.
Check the source

Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.