{"slug": "claude-code-s-400k-autocompact-default-every-setting-that-changes-it-and-what-it", "title": "Claude Code's 400K autocompact default: every setting that changes it, and what it does to the tokens a session re-reads", "summary": "Claude Code v2.1.334, released December 1, changed the default auto-compact window on 1M-context models (Fable, Sonnet 5 and later, Haiku 5.5, Opus 4.7 and later) to 400K, so compaction now runs at about 367K tokens instead of about 967K, according to the Claude Code model-configuration docs. The docs rank five ways to override the window — the CLAUDE_CODE_AUTO_COMPACT_WINDOW environment variable first, then the --autocompact flag, managed settings, a saved per-model /autocompact value, and the top-level autoCompactWindow — and note that the environment variable reads a bare number as tokens while the command and flag read 100–1000 as thousands. In a modeled session that adds 3M tokens, compacting at 367K re-sends 107M context tokens across 9 compactions, versus 244M across 3 compactions at 967K.", "body_md": "# Claude Code's 400K autocompact default: every setting that changes it, and what it does to the tokens a session re-reads\n\nClaude Code now compacts near 400K tokens by default on 1M-context models, down from about 967K. This page puts the five ways to set the window in order of precedence, lists the cases that still run to 1M, and models how much context a long session re-reads at each setting.\n\n**This explains reporting by**\n\n[Claude Code docs: Model configuration, compaction near 400K on a 1M model](https://code.claude.com/docs/en/model-config).\nRead the original first:\n\n[https://code.claude.com/docs/en/model-config](https://code.claude.com/docs/en/model-config)\n\n## In one minute\n\n- On models with a native 1M window (Fable, Sonnet 5 and later, Haiku 5.5, Opus 4.7 and later), the default auto setting now compacts at about 367K tokens instead of about 967K.\n- To get the old behavior for one model, run /autocompact 1M. To check what you have, run /autocompact with no value.\n- The environment variable beats everything, then the --autocompact flag, then managed settings, then your saved per-model window, then the top-level autoCompactWindow.\n- CLAUDE_CODE_AUTO_COMPACT_WINDOW=200 means 200 tokens, raised to the 100K minimum. /autocompact 200 means 200,000.\n- In our model of a session that adds 3M tokens, compacting at 367K re-sends 107M context tokens; at 967K it re-sends 244M, with 9 compactions against 3.\n\n## What changed\n\nClaude Code v2.1.334, released on December 1 per The New Stack, moved the default auto-compact window on current 1M-context models to 400K. Compaction now runs at about 367K tokens. Before, those models ran until about 967K.\n\nThe docs say compacting sooner keeps later requests smaller, so long sessions use fewer tokens. A one-time prompt titled \"Autocompact now defaults to 400k tokens\" lets you apply it to all models, the current model only, or keep your saved sizes. Closing the prompt changes nothing, which means auto at 400K.\n\nThe New Stack reports the change is rolling out in stages and was already live for users on third-party providers and users with telemetry off.\n\n## Which setting wins\n\nFive places set the window. From the docs, highest priority first:\n\n```\n1. CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000\n     environment; beats the flag, the command and every setting\n2. claude --autocompact 1M\n     one launch; beats every settings scope, saves nothing\n3. managed settings, modelSettings\n     \"claude-opus-5-5\": { \"autoCompactWindow\": 1000000 }\n4. /autocompact 1M\n     saved per model in your user settings\n5. \"autoCompactWindow\": 1000000\n     top-level, every model; a per-model value in the same file wins\n   none of the above\n     auto: 400K on current 1M models\n```\n\nEvery value is capped at the model's context window. With CLAUDE_CODE_DISABLE_1M_CONTEXT=1 the model is treated as 200K, and a larger window does not lift that.\n\nBefore v2.1.288, /autocompact saved one window for every model as the top-level key. If you set it back then, it now sits at priority 5 and a per-model save beats it.\n\n## Two traps\n\n- Units. The command and the flag read a bare number from 100 to 1000 as thousands, so /autocompact 200 sets 200,000. The environment variable reads a bare number as tokens, so CLAUDE_CODE_AUTO_COMPACT_WINDOW=200 means 200 tokens, which Claude Code raises to its 100K minimum with a warning. Write 200000, or 200k on v2.1.304 or later.\n- Idle compaction. A conversation you leave idle can still compact below the size you set. Turn off idle compaction if that matters to you.\n\n## Sessions that still run to 1M\n\nThe docs list four cases where a session on a current 1M model runs past 400K by default:\n\n- More than about 180K tokens of system prompt, tools and instruction files on every request: the window is raised for that conversation. The docs suggest trimming tools and instruction files instead of shrinking the window, because a small window can refill right after each compaction.\n- Resuming a conversation that is already past 400K: 1M until it compacts.\n- A Desktop scheduled task, a cloud scheduled task, or a session in a self-hosted environment: 1M.\n- A Claude Code version before v2.1.334: 1M. On Desktop, check the Code tab's version, which can differ from your terminal's.\n\n## The token math\n\nEvery request resends the whole context, so the tokens a session re-reads grow with how full the context gets before each compaction. We modeled a session that adds 6,000 tokens per turn on top of a 40,000-token system prompt and tools, and assumed each compaction leaves 60,000 tokens.\n\n``` python\ndef tokens_reread(trigger, new_tokens, per_turn=6000, base=40000, after=60000):\n    ctx, read, compactions, added = base, 0, 0, 0\n    while added < new_tokens:\n        ctx += per_turn; added += per_turn\n        read += ctx              # each request resends the whole context\n        if ctx >= trigger:\n            compactions += 1; ctx = after  # summary plus system prompt\n    return read, compactions\n\nfor new in (300_000, 1_000_000, 3_000_000):\n    for trigger in (367_000, 967_000):\n        print(new, trigger, tokens_reread(trigger, new))\nnew tokens added   compact at 367K        compact at 967K\n300,000            9.7M re-read, 0        9.7M re-read, 0\n1,000,000          34.9M re-read, 3       79.9M re-read, 1\n3,000,000          106.9M re-read, 9      244.1M re-read, 3\n```\n\nShort sessions see no change. Long ones re-send about 2.3 times as many context tokens at 967K. Changing the post-compaction size to 40,000 or 100,000 tokens moves that ratio only between 2.1 and 2.3.\n\nThe dollar gap is much smaller than the token gap. Most of those re-read tokens are prompt-cache reads, billed at a fraction of the input price; many sessions never reach either threshold; and each compaction costs its own summary call. The New Stack quotes Brian Scanlan of Fin, who A/B tested more than 700 Claude Code users: moving the trigger from 320K to 500K raised cost about 10% and halved the number of compactions.\n\n## Which to pick\n\n- Most work: keep auto. Scanlan says he found no quality drop in transcripts at the lower trigger.\n- A long refactor where losing an early detail is expensive: run /autocompact 1M for that model, or launch with --autocompact 1M for one session.\n- An organization that wants 1M everywhere: add a modelSettings entry per model version in managed settings. Developers can still override it with the flag or the variable.\n\n## Who is affected\n\n| Case | Status | \n|---|---|\n| Claude Code v2.1.334 and later on Fable, Sonnet 5+, Haiku 5.5, Opus 4.7+ | Compacts near 400K (about 367K) by default. | \n| Scheduled tasks, self-hosted sessions, resumed long conversations | Still 1M by default, per the docs. | \n| Scripts that set CLAUDE_CODE_AUTO_COMPACT_WINDOW to a small bare number | Read as tokens and raised to the 100K minimum. | \n\n## What to do\n\n- Run /autocompact with no value to see your window on each model you use.\n- Search your shell profiles and CI for CLAUDE_CODE_AUTO_COMPACT_WINDOW and fix any bare number under 1000.\n- Pick 1M per model only for work where an early detail matters more than tokens.\n\n## What is still unknown\n\n- Our token model is arithmetic with assumed turn sizes, not measured sessions. Real sessions vary turn to turn.\n- The Fin numbers come from an X post as quoted by The New Stack; we did not open the post.\n- The docs say Anthropic may set a different auto window for future models.\n- The release date of v2.1.334 is from The New Stack's report (\"Tuesday\").\n\n## Sources\n\n- [Claude Code docs: Model configuration, compaction near 400K on a 1M model](https://code.claude.com/docs/en/model-config) — the original report\n- [The New Stack: Claude Code will now summarize your session at 400K tokens instead of 1M (Dec. 4, 2026)](https://thenewstack.io/claude-code-400k-autocompact/)\n\n[AI News Report](https://theainewsreport.com/)· every headline, every morning.", "url": "https://wpnews.pro/news/claude-code-s-400k-autocompact-default-every-setting-that-changes-it-and-what-it", "canonical_source": "https://theainewsreport.com/2026-12-05-claude-code-400k-autocompact-settings-and-token-math.html", "published_at": "2026-12-05 17:40:02+00:00", "updated_at": "2026-12-05 18:13:41.241245+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "large-language-models", "ai-agents"], "entities": ["Claude Code", "Anthropic", "The New Stack", "Fable", "Sonnet 5", "Haiku 5.5", "Opus 4.7"], "also_reported_by": [], "takeaway": "Claude Code v2.1.334 now compacts at about 367K tokens by default on 1M-context models, and a modeled 3M-token session re-sends 107M context tokens across 9 compactions at that setting versus 244M across 3 at 967K.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/claude-code-s-400k-autocompact-default-every-setting-that-changes-it-and-what-it", "markdown": "https://wpnews.pro/news/claude-code-s-400k-autocompact-default-every-setting-that-changes-it-and-what-it.md", "text": "https://wpnews.pro/news/claude-code-s-400k-autocompact-default-every-setting-that-changes-it-and-what-it.txt", "jsonld": "https://wpnews.pro/news/claude-code-s-400k-autocompact-default-every-setting-that-changes-it-and-what-it.jsonld"}}