[BUG] Token Limit Hard-Stop Without Warning or Auto-Compaction
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?
Claude Code reaches the 200k token limit and abruptly stops mid-conversation without any proactive warnings or automatic compaction. The conversation hits a hard-stop displaying "Context limit reached · /compact or /clear to continue" with no prior indication that the limit was approaching.
Current problematic behavior:
- No proactive warnings - Users receive no notification when approaching the token limit (e.g., at 80%, 90%, or 95% usage)
- No automatic compaction - The conversation does not auto-compact to preserve recent context and continue working
- Hard-stop mid-task - Work stops immediately, potentially in the middle of complex multi-step operations
- Poor visibility - Token usage appears only in
<system_warning>tags within tool results, not in user-facing output - Data loss risk - Users may not know to
/exportbefore the limit is reached - Workflow disruption - Requires manual intervention (
/compactor/clear) to continue, losing momentum on active development tasks
This is a serious bug in Claude Code CLI's token management system that breaks the user experience during extended development sessions.
What Should Happen?
Claude Code should implement graceful degradation with progressive warnings and automatic compaction:
Progressive Warning System
At 80% token usage (160k/200k):
⚠️ Token usage: 160000/200000 (80%)
Consider running /compact to free up context, or save your work soon.
At 95% token usage (190k/200k):
⚠️ Token usage: 190000/200000 (95%) - Approaching limit!
Please run /compact now to continue working, or conversation will auto-compact in 30 seconds.
Automatic Compaction
At 98% token usage (196k/200k):
- Automatically compact the conversation to preserve recent context
- Display progress: "Auto-compacting conversation to free up tokens..."
- Continue working seamlessly without user intervention
- Preserve:
- Current task details
- Recent tool outputs
- User's original request
- Active file contents
Never Hard-Stop Mid-Conversation
The current hard-stop behavior should only occur as an absolute last resort, and if necessary, should happen gracefully at a task boundary (not mid-operation).
User Control
Provide settings to:
- Configure warning thresholds (default: 80%, 95%)
- Enable/disable auto-compaction (default: enabled)
- Set auto-compaction trigger point (default: 98%)
Error Messages/Logs
### Current Hard-Stop Message
⎿ Context limit reached · /compact or /clear to continue
✻ Cogitated for 33m 34s
### Token Usage in System Warnings (not visible to users in normal output)
<system_warning>Token usage: 48278/200000; 151722 remaining</system_warning>
[... many interactions later ...]
⎿ Context limit reached · /compact or /clear to continue
**Key issue:** Token usage warnings appear only in XML tags within tool results, not in user-facing conversational output. Users have no visibility into approaching limits.
### No Error Logs
The hard-stop does not generate error logs or stack traces - it simply displays the "Context limit reached" message and halts all interaction.
Steps to Reproduce
- Start a long development session with Claude Code CLI in any project:
``bash``
claude-code
- Engage in extended multi-step work that generates high token usage:
- Complex debugging sessions with multiple file reads
- Multi-file refactoring tasks
- Test generation workflows (multiple test files)
- Long implementation plans with review cycles
- Continue working without manually checking token usage - rely on the tool to warn you
- Observe: No warnings appear as token usage climbs (80%, 90%, 95%)
- Observe: At ~200k tokens, conversation hits hard-stop:
````
⎿ Context limit reached · /compact or /clear to continue
- Observe: No prior warnings were given in user-facing output
- Observe: No automatic compaction occurred
- Result: User must manually
/exportto save context, then/compactor/clearto continue
Minimal Reproduction Example
Since this requires reaching 200k tokens, here's an accelerated test scenario:
# 1. Start Claude Code
claude-code
# 2. Execute a token-heavy workflow (example)
# Ask Claude to read and analyze multiple large files repeatedly:
"Please read all TypeScript files in the src/ directory and provide detailed analysis of each"
"Now read all test files and compare them to the source files"
"Now generate comprehensive tests for each source file"
[Continue with similar requests until approaching 200k tokens]
# 3. Monitor token usage in system warnings (developer mode)
# Look for <system_warning>Token usage: X/200000; Y remaining</system_warning>
# 4. Observe no user-facing warnings at 80%, 90%, 95% thresholds
# 5. Observe hard-stop at 200k tokens with no auto-compaction
Environment Details
- Claude Code Version: Latest as of 2026-01-16
- Model: claude-sonnet-4-5-20250929
- OS: macOS (Darwin 25.2.0)
- Shell: GNU bash 5.3.9
- Session Type: Interactive CLI development session
Contributing Factors
This issue is particularly critical for:
- Power users with rigorous testing/review protocols (high token usage per task)
- Complex multi-file refactoring tasks
- Test generation workflows (multiple test files)
- Long debugging sessions with extensive file exploration
- Multi-step implementation plans with review cycles
Users following best practices (comprehensive testing, code review, documentation) naturally generate high token usage, making this bug a significant barrier to productive extended development sessions.
---
Additional Context
Workarounds (Current):
Users must manually:
- Monitor token usage in
<system_warning>tags (requires knowing where to look) - Periodically run
/compactpreemptively (disruptive to workflow) - Use
/exportbefore hitting limit to save context (requires anticipating the limit) - Run
/clearto hard-reset after hitting limit (loses all context)
Priority: High - This affects usability during extended development sessions and can cause data loss. The fix would significantly improve the user experience for power users working on complex tasks.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.9
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
15 Comments
Also, as of like version 2.1.6 you could use all of the tokens up to 200k, where as of 2.1.7, you are now locked out of using the remaining 25k-ish tokens, because of this new "Context limit reached" behavior. I have autocompact off, and understand I assume the risk of context exhaustion, but I'd rather have access to those 25k tokens to finish a package of work.
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Auto compaction isn't working in Claude.ai either since yesterday.
same thing in the VS code plugin
Yes, broken now.
Yes, same issue for a few days now (not sure which version, probably started around 2.1.7, now running 2.1.12).
Autocompact is on, yet claude happily runs into 100% crash.
<img width="254" height="131" alt="Image" src="https://github.com/user-attachments/assets/885e50a8-24fa-4e7b-ab4e-347fe8c8a63e" />
<img width="350" height="145" alt="Image" src="https://github.com/user-attachments/assets/407f6191-6607-4ad8-8ae1-540aa4f7bd75" />
I'm loosing access to more than 25k because of this issue. Here's a Reddit thread detailing similar behavior that I am seeing.
https://www.reddit.com/r/ClaudeAI/comments/1qczpzg/anyone_else_getting_context_limit_reached_in/
The issue of getting locked out of the last 35k-ish tokens even with autocompact off seems to have been fixed as of 2.1.14, even though the terminal warnings still are calculating the remaining context percent based on whatever the arbitrary cutoff amount was before. The release notes for 2.1.15 seem to say that the context-warning messages have been adjusted, but mine still act like they want to cut me off like what was happening when the bug was active. Thank you for the fix.
This behavior is catastrophic in a code-editing context. An assistant that modifies files must never abandon an edit halfway through execution. Doing so actively corrupts the user’s codebase and can waste significant time or cause real damage in production environments.
Claude must not:
Explicitly refuse to start the edit if it cannot be completed safely
Allowing partial edits to be written and then abandoned is grossly negligent behavior for a coding agent. It breaks the core trust assumption that automated code tools must be safe by default.
It is genuinely alarming that this has not been addressed earlier. In its current state, this behavior makes Claude unsafe for any non-trivial code editing workflow.
What Should Happen?
At an absolute minimum, the agent must:
Adding my voice — I'm using Claude Code for autonomous task execution and this is a blocker.
Issues I'm encountering:
I've also encountered the behavior where auto-compact fails to trigger even when enabled. Until this is resolved, any workflow relying on Claude Code for unattended, multi-step operations risks producing corrupt output or stalling entirely.
👍 on the progressive warning system and auto-compaction proposals. Atomic edit guarantees (finish current operation or rollback) would also be critical for safe automation.
Closed my ticket (#23966) as a duplicate of this issue.
Bump
Even worse: Claude 4.6 now takes the liberty of reverting to a previous commit without even asking, and just like that, your recent work is gone. This happened yesterday:
“You may need to re-apply those.” Right. Thanks for the heads-up, Claude — incredibly helpful after the fact. I had to manually restore everything, including changes that were built through a mix of unlimited GPT (web) research plus careful manual editing. Net result: over an hour of work burned because the tool decided to time-travel my repo without permission.
The hard-stop without warning happens when context silently fills past the limit. The guard daemon in Cozempic v1.4.1 monitors token usage continuously and fires pruning at configurable thresholds (gentle at 45%, hard at 75%) well before the limit.
17 strategies across 3 tiers keep sessions lean. Auto-starts via SessionStart hook — install once:
pip install cozempic && cozempic initAlso shows real-time token count and context usage % via
cozempic diagnose.@junaidtitan and the award for best project name goes to...
😅
Regards,
Junaid Ali Qureshi
On Fri, 3 Apr 2026 at 8:26 PM Andrew Rich @.***> wrote: