Back to all articles
NewsDecember 3, 2026·12 min read

Claude Code Auto-Compact at 400K - What the New Default Changes for 1M Sessions (2026)

You picked a 1M-context model in Claude Code so a long refactor could keep everything in view. Then, partway through the afternoon, the session compacts, and nowhere near 1M tokens. A notice says the session is on auto, which now compacts near 400K.

That's the new default. Claude Code v2.1.334, released on December 1, changed the per-model auto setting to compact near 400K tokens on most current 1M models. The release notes describe it as rolling out, and members of the Claude Code team posted about the change on X.

The short answer: on current models with a native 1M context window, Claude Code's documentation says "auto is 400K, so your session compacts near 400K tokens". The reason given is cost: later requests are smaller when compaction runs sooner. The 1M window itself is still there. If you want it, run /autocompact 1M, or set the window in settings for yourself, your organization, or a cloud repository.

This guide covers which models and sessions are affected, how to tell whether your session is on the new default, what the one-time prompt does, how to keep 1M, which sessions still run past 400K, and what compaction does to your working context either way.

What changed in v2.1.334

Claude Code compacts long conversations before they run out of room. Compaction replaces older history with a summary, so the session can keep going. What changed is when that happens on 1M models.

Before this release, a session on a 1M model on the default setting could run close to the full window before compacting. Now the default is a window Anthropic tunes per model, called auto. The model configuration page explains: "By default, your session uses auto, an auto-compact window that Anthropic tunes per model for the best cost and performance."

According to the release notes, the change also applies to -p runs and SDK runs. The same release added an Auto-compact window row to /config, so you can see and change the size there as well as with /autocompact.

A follow-up release, v2.1.335, fixed the one-time auto-compact prompt opening over a history search or menu. In the VS Code extension, it also fixed the context usage indicator showing full after a session went back from the 400K window to 1M.

Why Anthropic moved the default

The reasoning is about how tokens add up over a long session. Claude Code's cost guidance puts it simply: "Token costs scale with context size: the more context Claude processes, the more tokens you use."

Every message in a session sends the conversation so far. When a conversation sits at several hundred thousand tokens, each new turn carries all of it. Compacting earlier makes every later request smaller. The model configuration page says it directly: "Your later requests are smaller when compaction runs sooner, so long sessions use fewer tokens."

That applies whether you work against a plan's usage limits or pay per token through the API. A session that would have grown toward 1M now compacts into a summary at about 367K tokens and starts building again from there.

The trade-off is what the summary keeps. A summary is shorter than the conversation it replaces, so details that were only in chat can fall out. That's why the rest of this guide spends time on how to check the window, when to keep 1M, and what to write down before compaction runs.

Who should keep 1M and who shouldn't

The right window depends on the work, not the model.

Keep auto at 400K if your sessions are mostly focused tasks: a bug fix, a feature in one area, a review. A session like that which stays under 400K doesn't reach the new auto-compact point, so the change doesn't touch it.

Consider 1M if a single task needs a large amount of material in view at once, such as a migration across many files, a long investigation where earlier findings keep mattering, or work on a large generated file. In those cases, each compaction means Claude re-reads files and loses details that were only in chat.

Consider a smaller window if you work behind a gateway with a lower limit, or if you'd rather compact often and keep each session tight. The command accepts any size from 100K tokens up.

You can mix these. The window is saved per model, so one model can stay on auto while another keeps 1M.

Which models and sessions it affects

The 400K default applies to current models with a native 1M window. Claude Code's documentation lists them: "the Fable models, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later."

Other sessions follow different rules, and none of them changed:

  • Sonnet 4.6 and Opus 4.6 without extended context compact at the 200K boundary.
  • Native 1M models with CLAUDE_CODE_DISABLE_1M_CONTEXT=1 set compact at the 200K boundary.
  • Model IDs Claude Code doesn't recognize, such as a gateway alias, compact at the window Claude Code assumes for that ID.
  • Cloud sessions can compact before these thresholds.

If you work behind a custom ANTHROPIC_BASE_URL, the documentation points to a separate section on the context window behind a gateway. For how the 4.6 models reach 1M through their [1m] variant, and when that needs usage credits, see usage credits and 1M context in Claude Code.

What compacting near 400K means in practice

The window is the size the conversation can reach before compaction. Compaction itself starts a little earlier. The documentation says: "On auto at 400K, compaction runs at about 367K tokens."

That number can look confusing on the status line. Its used_percentage field counts against the full 1M, so when compaction runs on auto, the reading looks low. It isn't telling you how close you are to compaction.

The same applies if you set CLAUDE_CODE_AUTO_COMPACT_WINDOW. The documentation says that while the variable is set, the percentage "doesn't indicate when compaction will run".

How to tell if your session is on the new default

There are three ways to check.

The notice. A session on auto at 400K may show this message:

This session is on auto, which now autocompacts near 400k tokens instead of 1m to lower the cost of long sessions. To opt out, run /autocompact 1m.

The command. Run /autocompact with no value to see your session's window. In a resumed conversation, wait for a reply from Claude first.

The settings screen. Open /config and look for the Auto-compact window row.

Check again after you switch models. Anthropic says it continues to evaluate auto for future models and can set a different window.

The one-time prompt

Some people see a prompt titled Autocompact now defaults to 400k tokens. It asks which of your native 1M models should use auto at 400K. Here's what each answer does, based on the documentation's table:

  • Apply (all models). Those models move to auto, and you lose the sizes you saved for them.
  • Apply for the current model only. That model moves to auto. The others keep their saved size, or get 1M saved if they were on auto.
  • Keep. Your saved sizes stay, and models in your /model picker that were on auto get 1M saved. A model version released later has no saved size.

If you close the prompt without choosing, nothing changes in your settings, so models on auto compact near 400K. In a cloud session, your answer lasts for that session only. You can change your mind later with /autocompact 1M or /autocompact auto on the model you're using.

How to keep the full 1M window

Anthropic calls auto the recommended setting, and you can keep working as you are. If your work needs the full window, the documentation gives four routes.

For yourself, on one model

Run /autocompact 1M in your session. On your own machine, Claude Code saves the size for later sessions on that model version, and compaction then runs at about 967K tokens.

The saved value goes into your user settings under modelSettings, per model. To go back, run /autocompact auto.

For every model, or in scripts

Set autoCompactWindow in a settings file for every model. A size you saved for a model with /autocompact wins over this key in the same file. For one launch, start Claude Code with the --autocompact flag. In scripts and cloud environments, the CLAUDE_CODE_AUTO_COMPACT_WINDOW variable takes precedence over the command, the flag, and the setting.

For your organization

In managed settings, add a modelSettings entry for each 1M model version, such as "claude-opus-5-5": { "autoCompactWindow": 1000000 }. The documentation says the managed entry replaces the size a developer saved for that model. A developer can still override it with --autocompact or the environment variable.

If a computer running the Desktop app has no managed settings yet, the documentation also says to set parentSettingsBehavior to merge so Desktop's own policy still applies.

In cloud sessions

Run /autocompact 1M for the current cloud session. For later sessions on one repository, commit the same modelSettings entry to the repository's .claude/settings.json. Or add CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 to your cloud environment's variables, which applies to every model. A project's threads keep their own window.

Sessions that still run past 400K

Even on auto, some sessions use a larger window. The documentation lists these cases:

  • Large fixed context. If you send more than about 180K tokens of system prompt, tools, and instruction files with each request, the window is raised for that conversation.
  • Resumed long conversations. If you start by resuming a conversation already past 400K, such as with claude --resume, the window is 1M until it compacts.
  • Scheduled and self-hosted runs. Desktop scheduled tasks, cloud scheduled tasks, and sessions in a self-hosted environment use 1M.
  • Older versions. Claude Code versions before v2.1.334 use 1M. For a local Desktop session, check the Code tab's Claude Code version, which can differ from your terminal's.

If you see the notice Raised this conversation's auto-compact window, the documentation suggests using fewer tools or shorter instruction files rather than forcing a smaller window, "because a smaller window can refill right after each compaction".

Idle compaction still applies

The window controls compaction while you work. Separately, idle compaction can compact a long conversation you've stepped away from, before the prompt cache expires. The documentation says: "A conversation you leave idle can still compact below the size you set."

So setting 1M doesn't guarantee a session won't compact earlier. To prevent that, turn off the idleCompaction setting.

What compaction does to your working context

A smaller window means compaction happens more often in long sessions. It helps to know what comes back afterward. Claude Code's context window documentation explains: "When a long session compacts, Claude Code summarizes the conversation history to fit the context window."

A few things are restored on their own:

  • Recent files. Claude Code re-reads up to five of the files Claude has read or edited, choosing the most recently modified. A file over 5,000 tokens comes back as a path reference.
  • Most startup content, such as your project's root CLAUDE.md, reloads.
  • Skill bodies are re-injected, though large skills can be truncated.

Other things live only in the summary. Path-scoped rules and nested CLAUDE.md files load into message history when Claude touches their trigger files, so compaction summarizes them away. The same goes for anything you explained in chat: a decision about the approach, a constraint from a teammate, a test you agreed to skip.

You can steer what the summary keeps by running /compact yourself with a focus, such as /compact focus on the auth bug fix, before a long new task.

What people try first

Assuming the 1M window was removed. It's still there. Run /autocompact 1M to use it.

Reading the status line as a compaction meter. Its percentage counts against the full 1M.

Closing the prompt to keep 1M. Closing changes nothing, so auto stays at 400K.

Setting 1M in settings and expecting no early compaction. Idle compaction can still run.

Checking the terminal version for a Desktop session. The Code tab's version can differ.

The Fix: Choose a window on purpose, then make compaction cheap

Step 1: Check what your session uses

Run /autocompact with no value, or open /config, on each model you use.

Step 2: Pick a window per model

Keep auto for routine work. Save 1M for the models and repositories where long, unbroken context matters.

Step 3: Move durable decisions out of chat

Put rules that must survive compaction in the project-root CLAUDE.md, not in path-scoped rules or chat messages.

Step 4: Compact with a focus before big shifts

Before switching to a new task in a long session, run /compact with a short focus so the summary keeps what you need.

Setting this up in MemoryLake

CLAUDE.md is the right home for project rules. But some context isn't a rule: why you chose one approach over another, what a reviewer said last week, what's blocked and on whom. That context gets summarized away, and you may want it in other tools too.

MemoryLake is a memory layer for that kind of project context, kept in one place you maintain and available to the assistants you connect, such as Claude Code, Codex, and ChatGPT.

You write the entries yourself. Nothing is read out of, written to, or deleted from your Claude Code sessions, compaction summaries, CLAUDE.md files, settings, or any vendor's store. Compaction works the way Anthropic describes it.

Step 1: Create an API key

Sign in and generate a key from the dashboard. Keep it somewhere private.

The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent
The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent

Step 2: Upload your first memories

Start with the decisions from Step 3 of the fix that aren't rules: the reasoning behind your approach, open questions, and what's waiting on whom.

The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory
The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory

Step 3: Connect your AI & agents

Connect Claude Code, Codex, ChatGPT, and the other assistants you use, so the same context is available after a compaction and across tools.

The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer
The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer

What this changes in practice

The first difference is that compaction matters less. When the reasoning behind your work is written down, a shorter window costs you less.

The second is that a fresh session starts faster. A new session or a resumed one can pick up the same decisions without a long recap.

The third is consistency across assistants. If you plan in one tool and implement in Claude Code, both start from the same notes.

Best practices for the 400K default

Check the window on every model you use. Saved sizes are per model version.

Use 1M where long context matters. Save it for large codebases and long investigations.

Keep instruction files lean. Over about 180K tokens of fixed context raises the window for that conversation.

Commit repository settings for cloud work. A modelSettings entry in .claude/settings.json applies to later cloud sessions on that repository.

Turn off idle compaction if you need the full window. Otherwise a long idle conversation can still compact.

Update Desktop's Claude Code too. Its version can differ from your terminal's.

Compact with a focus. Tell the summary what to keep before it guesses.

Conclusion

Claude Code's auto window now compacts near 400K tokens on current native 1M models, starting with v2.1.334. Compaction runs at about 367K, and the status line's percentage still counts against 1M. The full window remains available through /autocompact 1M, modelSettings in user, managed, or repository settings, the --autocompact flag, or the environment variable.

Some sessions still run past 400K, and idle compaction can compact below any size you set. Whatever window you choose, keep durable rules in the root CLAUDE.md, compact with a focus before big shifts, and write down the reasoning you don't want summarized away.

Frequently asked questions

Did Claude Code remove the 1M context window?

No. The default auto-compact window on current 1M models is now 400K. Run /autocompact 1M to use the full window.

Which models compact near 400K by default?

Current models with a native 1M window: the Fable models, Sonnet 5 and later, Haiku 5.5, and Opus 4.7 and later.

When does compaction actually run at 400K?

At about 367K tokens, according to Claude Code's documentation.

How do I check my session's window?

Run /autocompact with no value, or look for the Auto-compact window row in /config.

What happens if I close the 400K prompt?

No setting changes, so models on auto compact near 400K.

Can an admin keep 1M for everyone?

Yes, with a modelSettings entry per 1M model version in managed settings. Developers can still override it with the flag or the environment variable.

Will setting 1M stop all early compaction?

Not on its own. Idle compaction can still compact a conversation you leave idle. Turn off idleCompaction to prevent that.