[BUG] Autocompact buffer (232.9k) exceeds 200k context window (116.5%) on Max plan — instant compaction loop after upgrading from 2.1.74
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?
Description
After upgrading from v2.1.74 to v2.1.76, Claude Code enters an infinite compaction loop immediately on session start. The session becomes completely unusable — "context limit reached" appears before any user input.
## Root Cause
Running /status on 2.1.76 reveals the problem:
- Context window: 200k tokens
- Autocompact buffer: 232.9k tokens (116.5%)
The autocompact buffer is larger than the entire context window. It appears the buffer is calculated for a 1M window (~23% of 1M = 232.9k) but applied against a 200k window. This leaves zero usable space, triggering immediate and infinite compaction.
## Screenshot
[attach the screenshot here]
## Environment
- Plan: Max ($100/mo)
- Working version: 2.1.74 (200k window, no issue)
- Broken version: 2.1.76
- Model: claude-opus-4-6
- Platform: macOS (Darwin 25.2.0, arm64)
- Setup: Multiple plugins enabled, 2 MCP servers, custom skills
## Workaround
Downgrade to 2.1.74:
```bash
ln -sf ~/.local/share/claude/versions/2.1.74 ~/.local/bin/claude
Notes
- CLAUDE_CODE_DISABLE_1M_CONTEXT=1 env variable did NOT fix the issue
- autoUpdates is set to false in settings
- The bug appears related to the 1M context feature added in 2.1.75 for Max plans — the buffer calculation seems to assume 1M even when the window is 200k
<img width="638" height="353" alt="Image" src="https://github.com/user-attachments/assets/e28fdfd4-d202-46c3-92e0-4b53588f1f5e" />
What Should Happen?
Of course, it should not behave like this, feels like a virus
Autocompact buffer should be sized relative to the actual context window (200k), not the 1M window.
Error Messages/Logs
Steps to Reproduce
- Be on Max $100/mo plan
- Have a working setup on v2.1.74
- Upgrade to v2.1.76
- Start a new session
- Immediately hits "context limit reached" and enters compaction loop
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.74
Claude Code Version
2.1.76
Platform
Other
Operating System
macOS
Terminal/Shell
Warp
Additional Information
_No response_
4 Comments
Your diagnosis looks correct — the buffer is calculated for 1M but applied against 200k.
A few additional things to try beyond the 2.1.74 downgrade:
1. Check for stale config
The 1M context feature may have persisted a setting that 2.1.74 ignores:
If you see anything context-related, try removing it and restarting.
2. Try a fresh session
If settings look clean, the buffer calculation might be cached in the session state:
Then immediately run
/statusto see if the buffer is still miscalculated.3. Model-specific test
Since the 1M context is tied to Opus, try starting with a different model to confirm it's model-specific:
If Sonnet works normally on 2.1.76, it confirms the buffer calc is leaking from the 1M Opus path into sessions that should use 200k.
4. The
CLAUDE_CODE_DISABLE_1M_CONTEXT=1failureThe fact that this env var didn't fix it suggests the buffer is calculated before the flag is checked, or the flag only affects context window display but not the autocompact threshold calculation. Worth mentioning this specifically in the bug report — it narrows down where in the code the miscalculation happens.
Thanks for your reply @yurukusa but unfortunately nothing works:
I manage to resolve this issue, no further action required from Anthropic
Root Cause Found
After 3 days of debugging, the issue was caused by two environment variables that Claude Code itself added to my
~/.zshrc:These were injected by Claude Code during a session (I did not add them manually). After the v2.1.76 upgrade, these values conflict with the new 1M context window calculations, causing the autocompact buffer (232.9k) to exceed the 200k window — triggering an infinite compaction loop on every session start.
Fix
Remove both lines from
~/.zshrc(or wherever your shell config lives), quit Terminal completely, and reopen.Recommendation to Anthropic
I install claude on Windows PC and another Macbook I have and only then I manage to figure out that this is local issue and found it eventually.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.