[BUG] "Context window discrepancy: UI shows 1% remaining when 45% actually available"

Resolved 💬 3 comments Opened Oct 3, 2025 by thomasingram-tmi Closed Oct 6, 2025

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:

  1. Is Cursor using a different model variant or context compression?
  2. Why does Claude Code appear more limited with the same base model?
  3. Is the 200K limit a Claude Code implementation constraint vs model limitation?

---
Steps to Reproduce:

  1. Start a Claude Code session
  2. Perform substantial work (read multiple files, write code, etc.)
  3. Check system warnings in responses: <system_warning>Token usage: X/200000; Y remaining</system_warning>
  4. Compare with UI-displayed context percentage
  5. 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:

  1. Check UI context calculation logic vs actual token tracking
  2. Verify if UI is counting something differently (total conversation tokens vs model context window?)
  3. Clarify expected context limits for Sonnet 4.5 in Claude Code vs other platforms
  4. Document if 200K is intentional Claude Code limit vs model capability

---

Error Messages/Logs

Steps to Reproduce

Steps to Reproduce:

  1. Start a Claude Code session
  2. Perform substantial work (read multiple files, write code, etc.)
  3. Check system warnings in responses: <system_warning>Token usage: X/200000; Y remaining</system_warning>
  4. Compare with UI-displayed context percentage
  5. 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_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗