[BUG] Statusline context_window JSON contains cumulative tokens instead of current context usage

Resolved 💬 14 comments Opened Dec 12, 2025 by alberduris Closed May 5, 2026

Description

The context_window data passed to custom statusline scripts contains cumulative/accumulated tokens from the entire session, not the current context window usage. This makes the statusline context display completely inaccurate.

Environment

  • Claude Code version: 2.0.65
  • OS: macOS 14.6.1 (Darwin 23.6.0)
  • Model: claude-opus-4-5-20251101

Steps to Reproduce

  1. Configure a custom statusline that displays context usage from the JSON input
  2. Have a conversation with multiple turns (enough to trigger auto-compact or use significant context)
  3. Compare the context_window values from the statusline JSON input vs /context command output

Expected Behavior

The context_window JSON passed to statusline scripts should reflect the current context window usage, matching what /context displays.

Actual Behavior

The JSON contains cumulative tokens that keep growing beyond the context window size:

From /context command (correct):

claude-opus-4-5-20251101 · 80k/200k tokens (40%)

From statusline JSON input (incorrect):

{
  "total_input_tokens": 330050,
  "total_output_tokens": 10614,
  "context_window_size": 200000
}

This results in 340k tokens shown for a 200k context window (169%), which is impossible and clearly wrong.

Debug Evidence

Statusline script outputs 339K/200K 169% while /context shows 80k/200k (40%).

The total_input_tokens and total_output_tokens appear to be session totals (all tokens ever sent/received), not the current context window contents. When auto-compact discards old context, these values are not adjusted.

Impact

  • Custom statuslines showing context usage are completely broken
  • Users cannot trust the context_window data in the statusline API
  • The feature added in v2.0.65 ("Added context window information to status line input") is unusable for its intended purpose

Suggested Fix

The statusline JSON should pass the current context window token counts (matching /context output), not cumulative session totals. Alternatively, provide both values with clear naming:

  • current_context_tokens - what's actually in the context window now
  • session_total_tokens - cumulative for the session (if useful)

Related Issues

  • #5601 - Custom Statusline auto-compact percentage incorrect
  • #12565 - Token counting discrepancy between transcript and /context
  • #3375 - Context left until auto-compact: NaN%

View original on GitHub ↗

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