claude-code - 💡(How to fix) Fix Status line shows 0.0k tokens and ctx% disappears after /compact

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

After running /compact, the status line immediately displays incorrect data:

  • Token count resets to 0.0k
  • ctx:% disappears entirely

The correct values only restore after sending the next regular message.

Root Cause

The status line reads context_window data from the most recent API response. After /compact, the most recent API call is the summarization request — a special call whose context_window fields (total_input_tokens, total_output_tokens, used_percentage) are either zeroed or null.

CC's internal context state is correct (visible via /context), but the status line only updates when a new regular chat completion response arrives.

Code Example

<path>  <model>  0.0k  5h:XX%  7d:XX%
branch main · clean
RAW_BUFFERClick to expand / collapse

Description

After running /compact, the status line immediately displays incorrect data:

  • Token count resets to 0.0k
  • ctx:% disappears entirely

The correct values only restore after sending the next regular message.

Steps to Reproduce

  1. Use Claude Code normally until context has meaningful usage (e.g. ctx:30%+)
  2. Run /compact
  3. Observe the status line immediately after compact completes

Expected Behavior

Status line should continue showing the correct context usage after /compact (matching what /context reports).

Actual Behavior

Status line shows:

<path>  <model>  0.0k  5h:XX%  7d:XX%
branch main · clean
  • Token count is 0.0k (should be ~30k+)
  • ctx:% is missing entirely

Running /context at this moment shows correct data (e.g. 32.8k / 200k (16%)), confirming the compact completed successfully and CC's internal state is accurate.

Root Cause Analysis

The status line reads context_window data from the most recent API response. After /compact, the most recent API call is the summarization request — a special call whose context_window fields (total_input_tokens, total_output_tokens, used_percentage) are either zeroed or null.

CC's internal context state is correct (visible via /context), but the status line only updates when a new regular chat completion response arrives.

Suggested Fix

After /compact completes, emit a status line update with the accurate post-compact context stats (sourced from CC's internal state rather than the compact API call's response headers).

Environment

  • OS: Windows 11
  • Claude Code: latest
  • Status line type: custom command

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING