[BUG] 2.1.159: autocompact silently disabled for non-remote sessions unless `autoCompactWindow` is set
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Starting in 2.1.159, automatic context compaction no longer fires by default for local (non-Remote-Control) sessions, regardless of how full the context is. The 2.1.159
changelog describes the release as "Internal infrastructure improvements (no user-facing changes)", but a runtime guard was added that gates autocompact behind
CLAUDE_CODE_REMOTE, an experiment flag, or an explicit autoCompactWindow / CLAUDE_CODE_AUTO_COMPACT_WINDOW setting.
For users who relied on autocompact firing automatically (the documented behaviour since 0.2.47), conversations now silently exceed the documented ~80% trigger and continue
running until the model itself errors with "Prompt is too long". There is no warning, no log line, and no /status indicator that autocompact has been short-circuited — the
failure mode is silent.
Root cause (from the JS bundle): a new early-return guard was added to the autocompact-decision function in 2.1.159:
``js``
// Present in 2.1.159, absent in 2.1.156
if (EDH() && !uc() && !K__(model, autoCompactWindow)) return false;
Where EDH() is true for non-remote sessions, uc() requires the tengu_amber_redwood3 experiment, and K__ is true only when autoCompactWindow came from settings.json
or the CLAUDE_CODE_AUTO_COMPACT_WINDOW env var. For a typical local user with none of those set, the function short-circuits to return false regardless of context fill.
Verifiable from any user's local binary cache:
``sh``
$ strings ~/.local/share/claude/versions/2.1.156 | grep -c "if(EDH()&&!uc()&&!K__"
0
$ strings ~/.local/share/claude/versions/2.1.159 | grep -c "if(EDH()&&!uc()&&!K__"
1
Related: #42149 asked for a way to disable autocompact and was closed as not planned. 2.1.159 effectively grants that, but as a default rather than an opt-in, and without
documenting it.
What Should Happen?
With autoCompactEnabled: true (the default), autocompact should fire automatically when the context approaches the threshold, as it has since 0.2.47. The 1.0.51 changelog set
this trigger to ~80%.
If gating autocompact behind explicit configuration is intentional, then at minimum:
- Document
autoCompactWindow,CLAUDE_CODE_AUTO_COMPACT_WINDOW,DISABLE_AUTO_COMPACT, andDISABLE_COMPACTin the public settings/env-var reference. - Add a 2.1.159 changelog entry naming the behavioural change.
- Surface the gate at startup or in
/status(e.g. "Autocompact is configured but inactive — setautoCompactWindowto enable").
Error Messages/Logs
(none — failure is silent; no warning, no log entry, no /status indicator)
Steps to Reproduce
- Use Claude Code 2.1.159 in a normal local session (not Remote Control;
CLAUDE_CODE_REMOTEunset). - Confirm
~/.claude/settings.jsondoes not containautoCompactWindow, andCLAUDE_CODE_AUTO_COMPACT_WINDOWis unset. - Confirm
autoCompactEnabledistrue(default). - Have a long conversation. Watch
/contextclimb past the documented ~80% trigger. - Observed: no compaction fires.
/contextkeeps climbing past 100%. Eventually the model itself returns "Prompt is too long". - Add
"autoCompactWindow": 160000to~/.claude/settings.json. Restart Claude Code. Repeat steps 4–5. - Observed: autocompact now fires as it did pre-2.1.159.
Reproducing the binary diff (any machine with both versions cached):
``sh``
strings ~/.local/share/claude/versions/2.1.156 | grep -c "if(EDH()&&!uc()&&!K__" # 0
strings ~/.local/share/claude/versions/2.1.159 | grep -c "if(EDH()&&!uc()&&!K__" # 1
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.156
Claude Code Version
2.1.159 (Claude Code)
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Workarounds (any one re-enables previous behaviour):
- Add to
~/.claude/settings.json:"autoCompactWindow": 160000(range accepted by the schema is 100000–1000000; 160000 ≈ legacy ~80% trigger on a 200K window). - Or env:
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=160000. - Or roll back:
ln -sf ~/.local/share/claude/versions/2.1.156 ~/.local/bin/claude(until next auto-update).
Timeline of autocompact in the public CHANGELOG (for context):
| Version | Entry |
|---|---|
| 0.2.47 | "Automatic conversation compaction for infinite conversation length (toggle with /config)" |
| 1.0.51 | "Increased auto-compact warning threshold from 60% to 80%" |
| 2.1.128 | First public mention of "autocompact window" (in a bugfix) |
| 2.1.149 | Bugfix for /config reporting phantom changes to auto-compact (confirms /config exposes a toggle) |
| 2.1.156 | Last version where the guard is absent — autocompact fires by default |
| 2.1.159 | Guard introduced; changelog reads only "Internal infrastructure improvements (no user-facing changes)" |
autoCompactWindow and CLAUDE_CODE_AUTO_COMPACT_WINDOW are not in the public docs at code.claude.com/docs and not in the changelog. Discovering the workaround required
disassembling the JS bundle.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗