What this thread does
Do first: run /autocompact with no value in Claude Code to see which auto-compact window your session uses. Model config
Short answer
On a model with a native 1M context window, Claude Code now compacts near 400K tokens by default, because the default window setting auto is 400K for current 1M models; the docs say this keeps long sessions cheaper. Model config To keep the full window, run /autocompact 1M; compaction then runs at about 967K tokens. Model config The change shipped in v2.1.334, described as rolling out, so some sessions may still differ. Changelog
Choose / don't choose
| Window | Choose it when | Not for |
|---|---|---|
auto (400K on current 1M models) | You want the setting Anthropic tunes per model; later requests stay smaller after earlier compaction | Work that needs a very long unbroken history in one conversation |
/autocompact 1M | You want the full 1M before compaction and accept larger requests | Cost-sensitive long sessions, since compaction runs later |
A smaller window such as 200000 | You want to compact earlier than auto, or a gateway rejects requests above 200K tokens | Models whose gateway really supports more; set the real window instead |
Settings that matter
| Setting | Behavior | Source |
|---|---|---|
/autocompact <value> | /autocompact <value> saves the current model’s window under user modelSettings, but a higher-priority settings scope can keep its own window active; an active CLAUDE_CODE_AUTO_COMPACT_WINDOW override is reported without saving, and /autocompact auto returns to the window tuned for your model. | Model config |
autoCompactWindow in a settings file | Window for every model; a window saved for a model with /autocompact wins over it in the same file | Model config |
claude --autocompact 500k | One launch only; overrides every settings scope, including managed settings | Model config |
CLAUDE_CODE_AUTO_COMPACT_WINDOW | For scripts and cloud environments; takes precedence over the command, flag and setting unless Claude Code ignores the value | Model config |
Managed modelSettings entry per 1M model | Keeps 1M for an organization, for example "claude-opus-5-5": { "autoCompactWindow": 1000000 }; replaces what a developer saved | Model config |
idleCompaction | A conversation left idle can still compact below your size; turn it off to prevent that | Model config |
Values need to be 100K tokens or more; a bare number from 100 to 1000 means thousands. In the environment variable a number with no suffix is tokens, so CLAUDE_CODE_AUTO_COMPACT_WINDOW=200 means 200 tokens. Model config
Order of operations
1. Run /autocompact with no value; in a resumed conversation wait for Claude's first reply before checking. Model config 2. If it reports auto at 400K and you want the full window, run /autocompact 1M; on your own machine the size is saved for later sessions on that model version. Model config 3. For a team, add the managed modelSettings entry for each 1M model version instead of asking everyone to run the command. Model config 4. For cloud sessions, run /autocompact 1M in the session, or commit the same modelSettings entry to the repository's .claude/settings.json, or set CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 in the cloud environment. Model config 5. If the one-time prompt "Autocompact now defaults to 400k tokens" appears, read the Apply and Keep table before choosing: Apply for all models drops sizes you saved. Closing the prompt changes nothing. Model config 6. After switching to a newer model, check again: the docs say Anthropic keeps evaluating auto and can set a different window for future models. Model config
Known failures and fixes
- Status line shows about 37% when compaction happens: on
autoat 400K compaction runs near 367K tokens, andused_percentagecounts against the full 1M. Model config - Compaction happens earlier than the size you set: idle compaction, or
CLAUDE_CODE_AUTO_COMPACT_WINDOWoverriding your command;/autocompactreports an override without saving. Model config - Warning that a variable reads as a few tokens or is ignored: write a token count such as
200000. Model config - Session runs past 400K on
auto: the docs list cases such as resuming a conversation already past 400K, scheduled or self-hosted sessions, versions before v2.1.334, and very large system prompts and tool lists. Model config - For a wrong gateway-alias window, update Claude Code if the model is newer than your version, or map a known model with
modelOverrides; useCLAUDE_CODE_MAX_CONTEXT_TOKENSonly after checking the ID-specific rules, because an unrecognized[1m]ID needsCLAUDE_CODE_DISABLE_1M_CONTEXT=1for a lower window, while a recognized ID requiresDISABLE_COMPACT, which disables compaction. Model config
Missing
- The docs do not give the exact rollout share, so a session may still behave differently from this page.
- The pages give no measured savings; the cost statement is Anthropic's.
Evidence
Claude Code docs, "Model configuration", and the Claude Code changelog entry for 2.1.334, both read 2026-12-03. 0 trials in this draft; not tried by WhatWorks.
Checked
2026-12-03; both pages were read as served on that date.
Started from a post by @Anthropic, packaged by the editor. Original post