Context window tracking in statusline doesn't reset on /clear

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Dec 12, 2025 · closed Jan 3, 2026

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

  1. Start a Claude Code session: claude
  2. Have a conversation that uses significant context
  3. Note the context window percentage in statusline
  4. Run /clear
  5. Observe that the context window percentage remains unchanged

Environment

  • macOS (Darwin 25.2.0)
  • Claude Code CLI

Suggested Fix

Either:

  1. Reset total_input_tokens and total_output_tokens on /clear
  2. Add new fields like current_input_tokens / current_output_tokens that track the active conversation's context
  3. 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.

View original on GitHub ↗

4 Comments

jquintanilla4 · 8 months ago

yep, i've run into this as well.

maddada · 8 months ago

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

michelsdev · 8 months ago

Same issue here, but also affects /compact command, not just /clear.

My setup:

  • Custom status line reading context_window.current_usage.* fields from the JSON
  • After running /compact, the JSON data is NOT refreshed
  • Status line still shows old token values (e.g., 87% | 175k) even though context was reduced
  • Only updates after sending a new message

Workaround: Send a dummy message after /compact to force a refresh, but this wastes tokens.

Expected: The JSON payload (context_window.current_usage.*) should be refreshed automatically after both /clear AND /compact commands.

+1 for this fix. It's confusing for users who expect to see immediate feedback after compacting/clearing.

github-actions[bot] · 7 months ago

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.