claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Status line context percentage doesn't match /context after /compact

Open Leoezlo opened this issue 11 months ago • 1 comments

Description

The status line context_window.current_usage data doesn't update after running /compact, causing the displayed context percentage to be significantly higher than the actual context usage shown by /context.

Steps to Reproduce

  1. Use Claude Code until context reaches ~70-80%
  2. Run /compact to compact the conversation
  3. Check status bar percentage vs /context output

Expected Behavior

After /compact, the status line should show the same (or similar) context percentage as /context.

Actual Behavior

  • Status bar shows: 72% ctx
  • /context shows: 45% (90k/200k tokens)

The /context command correctly shows the reduced context after compaction, but the status line continues displaying the pre-compaction percentage.

/context Output (after compaction)

Context Usage
90k/200k tokens (45%)

⛁ System prompt: 3.9k tokens (1.9%)
⛁ System tools: 15.8k tokens (7.9%)
⛁ MCP tools: 14.1k tokens (7.0%)
⛁ Memory files: 1.3k tokens (0.7%)
⛁ Messages: 10.1k tokens (5.0%)
⛶ Free space: 110k (54.9%)
⛝ Autocompact buffer: 45.0k tokens (22.5%)

Status Line Configuration

Using a custom status line script (as recommended in docs) that calculates:

current=$(echo "$input" | jq -r '
  if .context_window.current_usage then
    (.context_window.current_usage.input_tokens // 0) +
    (.context_window.current_usage.cache_creation_input_tokens // 0) +
    (.context_window.current_usage.cache_read_input_tokens // 0)
  else 0 end
')
pct=$((current * 100 / size))

This follows the documented approach but current_usage appears to retain pre-compaction values.

Environment

  • Claude Code version: 2.0.76
  • Model: Opus 4.5
  • OS: Windows 11 (Git Bash)
  • Account: Claude Max

Additional Context

The 27 percentage point discrepancy (72% vs 45%) suggests current_usage fields are not being reset/recalculated when the conversation is compacted. The data passed to the status line script appears stale.

🤖 Generated with Claude Code

Leoezlo avatar Dec 26 '25 20:12 Leoezlo


Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/13783
  2. https://github.com/anthropics/claude-code/issues/13653
  3. https://github.com/anthropics/claude-code/issues/14348

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code


github-actions[bot] avatar Dec 26 '25 20:12 github-actions[bot]

This issue has been automatically closed as a duplicate of #13783.

If this is incorrect, please re-open this issue or create a new one.

🤖 Generated with Claude Code

github-actions[bot] avatar Dec 30 '25 09:12 github-actions[bot]

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.

github-actions[bot] avatar Jan 06 '26 14:01 github-actions[bot]