Context window tracking in statusline doesn't reset on /clear
Description
The context_window data provided to statusline commands (total_input_tokens, total_output_tokens) does not reset when using /clear. This appears to track cumulative CLI session usage rather than the current conversation's context window.
Expected Behavior
After running /clear, the context window usage should reset to near-zero (just system prompt), since /clear starts a fresh conversation where Claude no longer has access to previous messages.
Actual Behavior
The total_input_tokens and total_output_tokens values continue to accumulate across /clear commands within the same CLI session. The statusline shows high context usage even after clearing the conversation.
Steps to Reproduce
- Start a Claude Code session:
claude - Have a conversation that uses significant context
- Note the context window percentage in statusline
- Run
/clear - Observe that the context window percentage remains unchanged
Environment
- macOS (Darwin 25.2.0)
- Claude Code CLI
Suggested Fix
Either:
- Reset
total_input_tokensandtotal_output_tokenson/clear - Add new fields like
current_input_tokens/current_output_tokensthat track the active conversation's context - Document that these fields are cumulative session totals, not current context
Use Case
Users rely on context window tracking to know how much context remains before hitting limits. After /clear, users expect a fresh start with full context available.
4 Comments
yep, i've run into this as well.
Similar issues here. I'm not sure if it's related to /clear or what but the value for the available context % that I see in the status line is always wrong compared to the value I see when running /context (which should be the source of truth)
Example:
/context
claude-opus-4-5-20251101 · 97k/200k tokens (48%)
⛁ System prompt: 3.4k tokens (1.7%)
⛁ System tools: 16.4k tokens (8.2%)
⛁ MCP tools: 19.1k tokens (9.6%)
⛁ Memory files: 270 tokens (0.1%)
⛁ Messages: 12.6k tokens (6.3%)
⛶ Free space: 103k (51.6%)
⛝ Autocompact buffer: 45.0k tokens (22.5%)
Statusline:
ai-devtools git:(main)✗ │ 123k/200k (61%) │ $1.02 │ +24 -3
v2.0.69 │ claude-opus-4-5-20251101 │ 200k tokens │ 10m
Same issue here, but also affects
/compactcommand, not just/clear.My setup:
context_window.current_usage.*fields from the JSON/compact, the JSON data is NOT refreshedWorkaround: Send a dummy message after
/compactto force a refresh, but this wastes tokens.Expected: The JSON payload (
context_window.current_usage.*) should be refreshed automatically after both/clearAND/compactcommands.+1 for this fix. It's confusing for users who expect to see immediate feedback after compacting/clearing.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.