Statusline context gauge freezes after compact - cumulative tokens never reset

Resolved 💬 2 comments Opened Jan 9, 2026 by bloknayrb Closed Jan 12, 2026

Description

The statusline context gauge stops updating after compacting when context was at 0% (100% used). The gauge remains frozen at 0% even after sending additional messages post-compact.

Root Cause

After debugging, I discovered that total_input_tokens and total_output_tokens in the statusline JSON data are cumulative session totals - they track every token ever sent/received in the session and never reset after compact.

Example from debug log (session 2e406459...):

14:43:22 - total_input_tokens: 223,372  total_output_tokens: 11,464  → 117% of 200k
14:46:39 - total_input_tokens: 223,428  total_output_tokens: 18,925  → 121% of 200k  
14:51:17 - total_input_tokens: 223,568  total_output_tokens: 19,509  → 122% of 200k

These values only ever increase, even after compacting should have freed up context.

Impact

Oh-my-posh (and likely any statusline integration) calculates token usage as:

(total_input_tokens + total_output_tokens) / context_window_size

Once this exceeds 100%, it stays there permanently because the counters never decrease - making the context gauge useless after a single compact from high usage.

Expected Behavior

After compacting, the statusline data should reflect actual current context usage, not cumulative session totals. Either:

  1. Reset total_input_tokens/total_output_tokens after compact to reflect actual context
  2. Or provide a separate field (e.g., current_context_tokens) representing actual context window usage

Environment

  • Claude Code version: 2.1.2
  • OS: Windows 11
  • oh-my-posh version: 28.10.0

Steps to Reproduce

  1. Use Claude Code until context reaches 0% remaining (100% used)
  2. Run /compact
  3. Send additional messages
  4. Observe statusline - context gauge remains frozen at 0%

Debug Data

Full statusline JSON showing the issue (note total_input_tokens never decreases):

{
  "context_window": {
    "total_input_tokens": 223568,
    "total_output_tokens": 19509,
    "context_window_size": 200000
  }
}

This was captured using a debug script that logs the raw JSON Claude Code pipes to the statusline command.

View original on GitHub ↗

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