You come back to a long Claude Code session after an hour away and Claude seems to have forgotten details that were in the conversation. It did not forget: it is idle compaction, which swaps the whole conversation for a summary when the session sits idle. To turn it off, put "idleCompaction": false in settings.json (Claude Code 2.1.290 or newer) or use the Idle compaction row in /config (2.1.302 or newer).
What is Claude Code idle compaction and when does it trigger?
It is an automatic compaction that runs while you are away from the session. According to the settings reference, it is on by default and only acts when all of the conditions below hold:
| Condition | What the docs say |
|---|---|
| Where | interactive terminal, the VS Code extension chat panel, or the desktop app Code tab (session on your machine or over SSH) |
| Auto-compact | autoCompactEnabled is on |
| Prompt cache | conversation is on the one-hour TTL |
| Size | context reached the 200,000 token threshold (configurable) |
| Idle time | about an hour since the last request, with your computer awake |
The intent, explained by a maintainer in issue anthropics/claude-code #106402, is to avoid a large charge when you resume a session after the cache has expired. The consequence is that Claude continues from a summary, not from the full conversation.
How do I tell my session was compacted on its own?
Look for the notice in the terminal. The docs quote a line that starts with Compacted while idle, before the prompt cache expired. In VS Code and the desktop app the text is similar and ends with the instruction to turn it off. The author of issue #106402 saw this variant:
Compacted after an hour idle, using a summary written while you were away · turn off with "idleCompaction": false in settings.json
If you saw that notice, the detailed context of that session was replaced and does not come back. A compaction cannot be undone inside the session.
How do I turn idle compaction off?
There are two documented ways, with the same result.
Through /config: open /config in a terminal session and change the Idle compaction row. Your choice is saved to your user settings and applies right away. The row requires Claude Code 2.1.302 or newer.
Through settings.json: the key works in any settings file and requires version 2.1.290 or newer.
{
"idleCompaction": false
}
If the row is missing from /config on the right version, the docs give two causes: another settings source sets the key (managed settings, the --settings flag, or a project or local file, which override your user settings), or, before 2.1.314, Claude Code could not fetch feature flags, in which case idle compaction does not run at all.
What if I only want it to trigger later?
Change the size threshold with the CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS variable. The default is 200000, values below 100000 are raised to 100000, and anything that is not a positive whole number is ignored. The variable also requires 2.1.290 or newer.
{
"env": {
"CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS": "600000"
}
}
The docs example uses 150000, to lower the threshold. Raising it, as above, only matters if your context window is larger than 200K (like the opus[1m] in the issue). On a 200K window, regular auto-compact acts before it gets there.
What about an older version that ignores the key?
Turn off auto-compact entirely. The docs say that turning off autoCompactEnabled turns idle compaction off too. For a single session, use the environment variable:
DISABLE_AUTO_COMPACT=1 claude
The cost is that you also lose regular auto-compaction near the context limit. Manual /compact keeps working. To turn off everything, manual included, there is DISABLE_COMPACT=1, which is rarely what you want.
Does idle compaction act while background agents are running?
According to one user, yes. In issue #106402 the author reports a code review in a background agent that started at 08:54 and was still writing files at 13:48. The main session had made no model call since 12:06, so when they sent a message at 13:47 it compacted at 207,101 tokens and dropped to about 24 thousand. The report covers a single run, on version 2.1.304, and the author notes they did not repeat the test. The official reply in the issue was that compaction can be turned off in settings.
The practical reading: if you leave long agents working in the background while the main session holds context it will need when they return, turn idle compaction off before you start. The context docs say background agents keep running after a compaction, but the summary is what the main session has as memory from then on.
How do I compact on my own terms instead of waiting for the automatic one?
Run /compact when you decide the conversation has done its job. The summary is under your control and can take instructions on what to keep. Verboo Code has the same command in the terminal, with a tutorial at /compact in Verboo Code.
In Verboo Code you decide when to compact with /compact, and tokens are unlimited: keeping a long session open does not weigh on your quota.



