Claude Code Auto-Compact at 400K: Check It, Go Back to 1M

Advertisement
Claude Code auto-compact now starts at 400K tokens Automation
Advertisement

Early in December, Claude Code greeted me with a prompt titled Autocompact now defaults to 400k tokens. Conversations that used to run close to a million tokens would now get summarized at 400K. I didn't want a long task compacted halfway through without knowing when it would happen, so I tested it on my own Windows PC.

I grew a conversation by about 41K tokens per turn. Nothing happened up to about 366K, and on the next turn, the one that would have pushed it past 400K, auto-compact kicked in. Since a smaller conversation also means lower usage, my recommendation is to leave it on the default (auto). If you really need to keep a huge amount of material in context, /autocompact 1m takes you back to 1M.

Chart of context size per turn on the default auto-compact setting
Each turn added about 41.5K tokens. After reaching about 366K on turn 8, the conversation was auto-compacted before turn 9 was sent and dropped to about 77K

What auto-compact is (and how it differs from /compact)

Claude Code sends the whole conversation back to the model on every request. As the conversation grows toward what the model can read at once (its context window), Claude Code replaces older turns with a summary so you can keep going. That is auto-compact. Running /compact does the same thing by hand.

Type When it runs How to turn it off
Auto-compact When the conversation nears the auto-compact window autoCompactEnabled set to false, or DISABLE_AUTO_COMPACT=1
/compact When you type it. You can add notes on what the summary should keep It only runs when you ask
Idle compaction When a conversation over 200K tokens sits idle for about an hour idleCompaction set to false

A summary loses the fine detail of earlier turns, like the contents of files Claude read and the trial and error along the way. You can keep working, but Claude may no longer remember that file from an hour ago in detail. On the other hand, if nothing compacts before the hard limit, you get input is too long, and even /compact can fail (here's how I got out of that).

What changed: from about 1M to about 400K

The change landed in v2.1.333. The changelog says the per-model auto setting moved to near 400K on most current models with a 1M context window. The docs list Opus 4.7 and later, Sonnet 5 and later, Haiku 5.5, and the Fable models. It also covers claude -p and SDK runs, though the changelog says that part is still rolling out.

According to the docs, compaction on auto at 400K actually runs at about 367K tokens, which leaves roughly 33K for writing the summary. Your session can still run past 400K in a few cases: when the system prompt, tools, and instruction files you send every time add up to more than 180K, when you resume a conversation that is already past 400K with --resume, or when you run a version older than v2.1.334. The stated reason is cost: compacting sooner keeps later requests smaller, so long sessions use fewer tokens.

Testing the 400K threshold on my PC

I updated Claude Code from 2.1.334 to 2.1.337 first. Filling a conversation to 400K costs usage, so I used the cheaper Haiku 5.5 and called claude -p again and again on the same session. Each turn sent about 41.5K tokens of log lines with an instruction to reply with just OK. From the output of each turn, I recorded the context size and whether a compaction happened.

Turn Context size Compaction
1 to 7 about 75K to 324K No
8 about 366K No
9 about 77K Yes (summarized before sending, about 7 seconds)
10 about 118K No (growing again)

Turn 8 landed at 366K, just under the documented 367K, and went through untouched. Adding turn 9 would have taken it past 400K, so the conversation was summarized down to about 27K first, and the new chunk brought it to about 77K. All ten turns moved my 5-hour usage from 6% to 7%.

On Opus 5.5, which I use day to day, /context also showed a 400k limit, with 33k (8%) set aside as Autocompact buffer. That matches the roughly 33K the docs describe.

/context on Opus 5.5
/context on Opus 5.5 shows 44.4k/400k tokens. The second line from the bottom reads Autocompact buffer: 33k (8%)

How to check your auto-compact threshold

To see where your session will compact, run /autocompact with no value.

/autocompact
/autocompact with no value
It says Current setting for Opus 5.5: auto (400k tokens). Arrow keys move the slider, Enter saves, and Esc leaves it unchanged

Pressing Enter here saves a value, so close it with Esc if you only want to look. To see how full the conversation is right now, use /context. The Auto-compact window row in /config shows the same setting.

/context
Auto-compact rows in /config
In /config, Auto-compact is on, Auto-compact window is auto (400k tokens), and Idle compaction is on

Go back to 1M, compact earlier, or turn auto-compact off

To get the old behavior of about 1M back, run this inside Claude Code. It is saved to your user settings for the current model, so later sessions use 1M too (compaction then runs at about 967K).

/autocompact 1m

To return to the 400K default, set it back to auto.

/autocompact auto

If you would rather compact even earlier to save usage, pick a smaller value such as 200K. The minimum is 100K.

/autocompact 200k

For a single launch, use the command-line flag, which isn't saved.

claude --autocompact 1m

To turn auto-compact off entirely, add this to ~/.claude/settings.json (switching Auto-compact off in /config does the same). Idle compaction stops with it, while /compact still works when you type it.

{
  "autoCompactEnabled": false
}

To turn it off for one session only, set the environment variable in PowerShell before you start Claude Code.

$env:DISABLE_AUTO_COMPACT = "1"
claude

With it off, the session stops at the hard limit with Prompt is too long, so plan on running /compact yourself at good stopping points. If only the idle compaction bothers you, use this instead.

{
  "idleCompaction": false
}

Things that tripped me up

1. --autocompact had no effect with -p

I ran the same test with --autocompact 1m and with --autocompact 200k. With 1m it still compacted on turn 9, just like the default. With 200k it never compacted, even at about 283K. There was no error or warning either time. If a claude -p script depends on a custom window, check the compact_boundary line in the --output-format stream-json output to confirm where compaction actually happened.

2. The 400K prompt only shows up once

The Autocompact now defaults to 400k tokens prompt is a one-time question, and it didn't appear when I launched 2.1.337 for this test. If you see it, Apply moves your models to 400K. Keep saves your current values, and models that were on auto get 1M saved. Closing it saves nothing, so you stay on 400K. You can change your mind later with /autocompact.

3. A resumed conversation showed 1M

When I opened my test conversation with claude --resume and checked /context, it said Auto-compact window: 1m tokens. The docs say a conversation already past 400K gets 1M when resumed, until it compacts. If you pick up a long conversation the next day, a quick look at /context tells you which window you're on.

Summary

Since Claude Code 2.1.333, auto-compact starts at about 400K (really about 367K) instead of about 1M. On my PC it compacted right after 366K. A smaller conversation means less re-reading on every request and lower usage, so stay on auto and switch to /autocompact 1m only when you need the room.

References

Comments

Copied title and URL