[Bug] Context limit reached prematurely - /context shows 74.4% remaining but context blocked
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?
/context command shows 70%+ free space available, but Claude Code still blocks further execution with "Context limit reached · /compact or /clear to continue" error message. This prevents continued workflow despite abundant remaining context capacity.
What Should Happen?
Claude Code should allow continued execution when /context shows >50% free space remaining. The context limit check should align with actual remaining capacity. If approaching true system limit, /context display should show accurate warning (e.g., <10% remaining) instead of blocking at 70% free space.
Error Messages/Logs
Context limit reached · /compact or /clear to continue
/context output at time of error:
- Total capacity: 200k tokens
- Tokens used: 46k (23%)
- Free space: 154k (77%)
- Autocompact buffer: 45.0k tokens (22.5%)
Steps to Reproduce
- Start Claude Code v2.1.15 (latest)
- Begin working on a project with moderate context usage (e.g., browser automation with screenshots, API responses, code reviews)
- Run
/contextcommand to check available capacity - Observe that /context shows 70%+ free space remaining (e.g., 77% in the reported case)
- Attempt to continue work or make another request
- System blocks execution with: "Context limit reached · /compact or /clear to continue"
- User cannot proceed despite having abundant capacity shown in /context output
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.15
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Impact Analysis:
This bug severely impacts workflows involving:
- Large file operations (screenshots, binary data)
- Browser automation with CDP (Chrome DevTools Protocol)
- API integration work with large responses
- Code reviews with full file contexts
Context Accounting Issue:
The discrepancy suggests the context limit check may be:
- Not properly accounting for free space during calculation
- Using a different/hidden threshold than displayed in /context
- Prematurely blocking based on internal state tracking
Workaround: Users must manually run /compact or /clear despite having 70%+ available capacity, losing context history unnecessarily.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗