[BUG] "Context window discrepancy: UI shows 1% remaining when 45% actually available"
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?
Issue: Claude Code UI shows context usage at 99% (1% remaining) while internal system warnings indicate only
55% context usage (45% remaining).
Evidence:
- System warning shows: Token usage: 110484/200000; 89516 remaining
- This equals 55.2% used, 44.8% remaining
- UI displays: 1% remaining (99% used)
- Discrepancy: 44% difference between actual and displayed context usage
Impact:
- User believes context is exhausted and session needs restart
- Disrupts workflow unnecessarily
- Causes confusion about when auto-compact will trigger
What Should Happen?
---
Description:
Issue: Claude Code UI shows context usage at 99% (1% remaining) while internal system warnings indicate only
55% context usage (45% remaining).
Evidence:
- System warning shows: Token usage: 110484/200000; 89516 remaining
- This equals 55.2% used, 44.8% remaining
- UI displays: 1% remaining (99% used)
- Discrepancy: 44% difference between actual and displayed context usage
Impact:
- User believes context is exhausted and session needs restart
- Disrupts workflow unnecessarily
- Causes confusion about when auto-compact will trigger
---
Comparison with Cursor:
Using the identical model (Sonnet 4.5):
- Cursor: Provides ~1M token context window
- Claude Code: Limited to 200K token context window
- Expected: Both should have same model limits (~200K for Sonnet 4.5)
Questions:
- Is Cursor using a different model variant or context compression?
- Why does Claude Code appear more limited with the same base model?
- Is the 200K limit a Claude Code implementation constraint vs model limitation?
---
Steps to Reproduce:
- Start a Claude Code session
- Perform substantial work (read multiple files, write code, etc.)
- Check system warnings in responses: <system_warning>Token usage: X/200000; Y remaining</system_warning>
- Compare with UI-displayed context percentage
- Observe discrepancy
---
Expected Behavior:
UI context indicator should match internal token usage tracking:
- If system reports 110K/200K used (55%), UI should show ~55% used
- Context warnings should be consistent across UI and system messages
---
Actual Behavior:
UI shows 99% used while system reports 55% used - 44 percentage point discrepancy.
---
Additional Context:
This issue was discovered during a session involving:
- Reading brain files (~10K tokens)
- Database schema work
- WebSocket event analysis
- Multiple file edits and queries
Session was productive and not near actual context limits based on system warnings, but UI suggested immediate
restart was needed.
---
Suggested Investigation:
- Check UI context calculation logic vs actual token tracking
- Verify if UI is counting something differently (total conversation tokens vs model context window?)
- Clarify expected context limits for Sonnet 4.5 in Claude Code vs other platforms
- Document if 200K is intentional Claude Code limit vs model capability
---
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce:
- Start a Claude Code session
- Perform substantial work (read multiple files, write code, etc.)
- Check system warnings in responses: <system_warning>Token usage: X/200000; Y remaining</system_warning>
- Compare with UI-displayed context percentage
- Observe discrepancy
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
OS: Linux (6.5.11-4-pve)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Non-interactive/CI environment
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗