On Wednesday 14 October the changelog for Claude Code 2.1.299 gained a line that reads like a new feature: "a 200K+ token conversation left idle for about 54 minutes is compacted before its one-hour prompt cache expires, so your next message doesn't reprocess it all." It is not new. The behavior went live in 2.1.286 on 30 September, switched on by a server-side feature flag, with no setting to turn it off and no mention in that release's notes. A user who woke up on 1 October to find seven overnight sessions summarized, none of them near the context limit, filed the first bug report that day. The idleCompaction setting that answers it shipped in 2.1.290 on 5 October, also without a changelog line, and the /config row that exposes it arrived in 2.1.302 on 16 October.

The economics are the reason it exists. Claude Code requests the one-hour cache TTL for your main conversation when you are on a subscription within your plan's usage. A 200,000-token conversation that sits past the hour comes back cold, and the next message rewrites the whole prefix at the one-hour cache-write rate, $8 per million tokens on Opus 5.5, or $1.60 at list price. Compacting at minute 54 instead reads the same prefix from cache for $0.04, writes a summary of roughly 20,000 tokens for about $0.40, and lets the next turn re-cache 25,000 tokens for $0.20. Every turn after that reads 20,000 tokens instead of 200,000. On an API key or a cloud provider the TTL is five minutes by default, so there idle compaction never runs unless you set the one-hour TTL yourself.

What it costs is the thing the cache was holding. The summary is written with no instructions, at a time chosen by a timer, from a conversation you had not finished. Path-scoped rules, nested CLAUDE.md files and anything a hook injected mid-session are summarized away with everything else; Claude Code re-reads at most five files afterwards and re-injects skill bodies capped at 5,000 tokens each. The transcript records the compaction as trigger: "auto", the same value as a compaction at the context limit. That was an improvement: in 2.1.286 it was recorded as "manual", as if you had typed /compact. A PreCompact hook can block it with exit code 2, but only by blocking every automatic compaction, unless the hook checks the clock itself.

Fourteen days before the changelog line

The request is older than the feature. Issue 66115, opened on 7 June, asked for an auto-compact on idle timeout "to prevent cache expiry cost," when the cache lasted "roughly 5 minutes." It got no maintainer reply. On 30 September, 2.1.286 shipped with nothing in its notes about idling. The next morning issue 98747 reported that "idle sessions are compacted automatically before the prompt cache expires," quoted the notice, "Compacted while idle, before the prompt cache expired," and asked for an opt-out, a distinct trigger value and hook support. On 2 October an Anthropic engineer, blois, replied: "Appreciate the feedback, setting is coming. Currently it's doing this only for larger contexts (200k+)."

The setting came in 2.1.290 on 5 October. blois confirmed it the next day: "Version 2.1.290 now has a idleCompaction setting to allow opting out, and the trigger is now 'auto'." The release notes for 2.1.290 run to about 200 lines and do not contain the word idle. A community member read the setting's description out of the binary, which is how it was documented for the next eight days. On 7 October a plugin called claude-cache appeared in the June thread doing the same thing as an opt-in, 55 minutes into the hour.

The reports kept coming from people who did not know the feature existed. Issue 101067 on 10 October described compactions on 2.1.296 firing between 281,107 and 844,686 tokens on a model with a 1M window, each carrying the idle notice and each about 54 minutes after the last message; the same reporter's 47 earlier compactions had all landed between 966,331 and 980,835 tokens. Issue 101616 on 12 October counted 13 idle compactions in two days across 2.1.292, 2.1.295 and 2.1.296, at sizes from 209,000 to 783,000 tokens, and concluded "it seems to be a server-side rollout rather than something introduced in one release." Its reporter's line is the whole complaint: "I would rather pay the uncached re-send on the first turn back than lose that context."

Then the changelog caught up. 2.1.299 on 14 October documented the feature and the setting in two bullets, adding that "Both need v2.1.290 or later." Issue 102260 on 15 October named the flag, tengu_sunny_locket, read out of the 2.1.300 binary with modes log, compact and compact_on_return and a default of "off", and quoted a second notice: "Compacted after an hour idle, using a summary written while you were away." 2.1.302 on 16 October added the /config row and made the notices say how to turn it off.

What the binary on my Mac says

My install is 2.1.295, a 240 MB arm64 executable dated 8 October, after the setting and before the changelog line. Its strings include the setting's description, which doubles as a warning: "Set to false to stop Claude Code from compacting a long conversation while the session is idle. Setting it to true does not turn idle compaction on." The flag name tengu_sunny_locket sits a few bytes from CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS, minTokens and fireAtFraction, which fits the community's reading that it fires at 90% of the TTL. There is a SleepCompactor with an isSleepCompactionHost check, and two telemetry events, tengu_idle_compact_fired, which carries a lateMs field, and tengu_idle_compact_settled. The three mode names found in 2.1.300 are not in 2.1.295.

The documented conditions are five. You are in an interactive terminal session, not the desktop app or VS Code. The conversation is on the one-hour TTL. Claude Code can fetch feature flags from Anthropic, which it does not do on Bedrock, Google Cloud's Agent Platform, Foundry, through a Claude apps gateway, or with DISABLE_TELEMETRY or DO_NOT_TRACK set. The context has reached 200,000 tokens. And about 54 minutes have passed since the last request "and your computer is awake at that point." The threshold moves through CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS, with values below 100,000 raised to 100,000; the 12 October reporter asked for 700,000.

What the hour is worth

The one-hour TTL is itself a choice Claude Code makes for you, in one billing situation. The docs put every request in two buckets. The main conversation gets one hour "only on a Claude subscription within your plan's included usage." Usage credits, API keys and cloud providers get five minutes, because one-hour cache writes cost twice the base input rate against 1.25 times for five-minute writes, and once you are billed per token Claude Code picks the cheaper write. Subagents, workflows, forks, session titles and the compaction request itself sit in the other bucket and get five minutes, apart from a few helper requests Anthropic controls server-side.

So the feature protects a cache that exists, by default, only for subscribers, whose cold rebuild is counted in plan usage rather than dollars. The arithmetic holds in token weights. At Opus 5.5 list prices a 200,000-token prefix costs $1.60 to rewrite for an hour and $0.04 to read; on Sonnet 5.5 it is $0.80 and $0.02. The compaction request, which Anthropic's April engineering post describes as using "the exact same system prompt, user context, system context, and tool definitions as the parent conversation," reads the warm prefix and produces a summary a figure in the same post puts at about 20,000 tokens. That is $0.40 of output on Opus, spent at minute 54 whether or not you come back, and spent even if you come back at minute 58 with the cache still warm.

The compact_on_return mode in the 2.1.300 binary and the second notice, "using a summary written while you were away," read like the fix for that last case: write the summary while the cache is warm, apply it only if you return after the cache is gone. Anthropic has not described the modes or said which one is on for whom. The notice people quote from the versions in the field is the first one.

What the summary drops

The context-window docs are specific about what survives. The system prompt, output style, project-root CLAUDE.md, auto memory and the plan file come back from disk. Up to five files Claude read or edited are re-read, most recently modified first, with anything over 5,000 tokens reduced to a path reference. Invoked skill bodies come back at 5,000 tokens per skill and 25,000 in total, oldest dropped first. Everything else, including "context that hooks added earlier," is "summarized with the rest of the conversation." Rules with paths: frontmatter and nested CLAUDE.md files load into message history when their trigger file is touched, so "compaction summarizes them away with everything else."

The 16 October comment on issue 102260 is the practical version: idle compaction "removed instructions and conditionally loaded files, so the agent forgot them." The 1 October version was that it "discards the grounding the session was built on." Neither is a bug in the summarizer. Claude Code's own cost page tells you to run /compact "at a natural break in your work, such as between tasks, instead of waiting for auto-compaction to trigger mid-task." Idle compaction triggers at a break in your attendance, which is not the same thing.

The other summaries it writes without asking

Idle compaction is one of three automatic summarizations that reached the changelog in the same week. 2.1.301 on 15 October improved model switching: "a conversation too long for the new model is now summarized by the previous model first." 2.1.302 on 16 October improved auto mode with the server-side classifier: "a conversation too long for the safety check is now compacted, instead of every checked tool call being denied," extending a change between 2.1.286 and 2.1.290 that did the same for the client-side classifier. In each case the alternative was worse, a failed request or a denied tool call, and in each case what resolves it is a summary you did not ask for, written by whichever model was holding the conversation.

The hooks reference lists idle compaction under the auto matcher for PreCompact and PostCompact. Issue 101070, opened on 10 October and labeled "Low - Nice to have," asks for a separate idle value; a comment on 16 October confirmed that 2.1.300 and 2.1.301 still report auto. Until that changes, a hook sees trigger: "auto" and custom_instructions: null for an idle compaction and for one at the context window alike, and the docs warn that blocking the second kind while it is recovering from a context-limit error makes the current request fail.

What to do

If you want the context more than the cache, set "idleCompaction": false in any settings file, which needs 2.1.290 or later; on an earlier version, autoCompactEnabled: false is the only switch and it also stops compaction at the limit. DISABLE_AUTO_COMPACT=1 does the same from the environment. If you want the feature but not on design conversations, raise CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS to a size you would be happy to see summarized.

If you want it to ask, a PreCompact hook on the auto matcher can block with exit code 2, and it can tell idle from threshold on its own: the hook receives transcript_path, and a transcript whose last write is more than 50 minutes old should be an idle compaction. Block those and let the rest through. The /usage command's Prompt cache (main) line shows which TTL you are on and how long the session has been idle, and the OpenTelemetry api_request event has split cache writes into cache_creation_5m_tokens and cache_creation_1h_tokens since 2.1.300, so an organization can see what the hour costs.

If you are on an API key and want the saving, set promptCacheTtl to 1h, accept the doubled write rate, and idle compaction applies to you under the same conditions. What no setting gives you is notice when a flag changes what the tool does to your work. The flag's default in the binary is off. Its default in practice was on for two weeks before a release note said so.