[BUG] Compaction fails with "context window limit" error even when context usage is low (e.g., 20%) — regression in v2.1.153
Resolved 💬 7 comments Opened May 28, 2026 by haozhongh Closed May 29, 2026
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?
After updating from v2.1.140 to v2.1.153, automatic compaction no longer triggers. Manually running /compact fails with a context window limit error, even though the displayed context usage is only around 20%. This creates an unrecoverable dead-end where the
conversation cannot continue and /clear is the only way out, losing all progress.
What Should Happen?
- Automatic compaction should trigger during extended conversations, as it did in v2.1.140
- Compaction should succeed when context usage is low (20%)
- If compaction fails, there should be a fallback mechanism rather than leaving the session unrecoverable
Error Messages/Logs
Error: Error during compaction: API Error: The model has reached its context window limit.
This error appears both when automatic compaction attempts to run and when manually executing /compact.
Steps to Reproduce
- Today I Update Claude Code from v2.1.140 to v2.1.153
- Start a conversation and work normally for an extended period
- During normal usage, an error suddenly appears: API Error: The model has reached its context window limit.
- Observe that automatic compaction never triggered on its own
- Notice that context usage remains low (around 20%)
- Manually run /compact → fails with the same error
- Session is now unrecoverable — only /clear works
Claude Model
Other
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.140
Claude Code Version
2.1.153
Platform
Other
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
- This is a regression — compaction worked correctly in v2.1.140
- No large files were read during the session — context grew through normal conversation and tool usage
- The error message claims "context window limit" but usage is only ~20%, suggesting hidden context (system prompts, tool definitions, etc.) may be inflating the actual token count beyond what the usage indicator shows
- Claude Code CLI, macOS (Darwin 25.5.0)
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗