[BUG] Auto compact does not trigger at 100% context window and Claude Code stops itself on cli
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?
Auto compact does not trigger automatically when the context window reaches 100%.
I am using Claude Code CLI on Arch Linux with the latest version, currently 2.1.168. During long coding sessions, the context window eventually reaches 100%, but Claude Code does not automatically compact the context. Instead, it stops itself / becomes unable to continue reliably, and I have to manually intervene.
I have tried adding instructions to my CLAUDE.md telling Claude Code to compact automatically or preserve context more aggressively, but it does not change the behavior. The problem still happens.
This has been happening for roughly the last 12 Claude Code versions, not only the current release.
The main issue is that auto compact appears to be enabled or expected, but when the context reaches the limit, no automatic compaction happens. Claude Code simply reaches 100% context and stops / blocks progress instead of compacting and continuing the task.
What Should Happen?
Claude Code should automatically compact the conversation/context before or when the context window reaches 100%.
Expected behavior:
- Detect that the context window is close to full or already at 100%
- Automatically compact the context without requiring manual
/compact - Preserve the important project state, task plan, files changed, decisions, and next steps
- Continue the coding session after compaction
- Avoid stopping itself just because the context window reached 100%
If auto compact is not supposed to work this way, the CLI should clearly document what the setting actually does and when it is expected to trigger.
Error Messages/Logs
No traditional stack trace is shown.
Observed behavior:
- Context window reaches 100%
- Auto compact does not run
- Claude Code stops itself / cannot continue the task reliably
- Manual `/compact` is required
- Adding instructions to CLAUDE.md does not change the behavior
Example warning/context state:
Steps to Reproduce
- Install or update Claude Code CLI to the latest version.
Current version used:
```bash
claude --version
# 2.1.168
Claude Model
Other
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Not sure. This has been broken for approximately the last 12 Claude Code versions.
Claude Code Version
2.1.168
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Non-interactive/CI environment
Additional Information
Environment:
- OS: Arch Linux
- Claude Code version: 2.1.168
- Shell: ZSH
- Project type: large real-world codebase
- Usage pattern: long-running coding sessions with many edits, tests, file reads, and follow-up prompts
-------
I tried to mitigate this by adding context-management and auto-compaction instructions to CLAUDE.md, but it does not affect the behavior. Once the context window reaches 100%, Claude Code still does not automatically compact.
This makes long-running coding sessions unreliable because Claude Code can stop itself at the context limit instead of preserving state and continuing.
This has been reproducible for approximately the last 12 Claude Code versions.
This issue has 13 comments on GitHub. Read the full discussion on GitHub ↗