-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
[Bug] TUI / status-message Context % shows cumulative session usage as numerator (>100%, e.g. 228%) #83526
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
The "Context" line in the TUI and
/statusoutput reports cumulativesession token usage divided by the model's context window, producing
nonsensical percentages like
2.3m/1.0m (228%)even withCompactions: 0and no actual context overflow. This is the same root cause as #55217
(closed for Web UI) but the fix did not propagate to the
status-message-*.jspath used by TUI and channel status cards.Example status output
Current turn is 16 input + 5.1k output. The 2.3m number is cumulative
cache reads across the session, not the prompt size of the current
request.
Compactions: 0confirms the actual context never overflowed(Anthropic would have rejected the request otherwise).
Root cause (dist code reference)
In
dist/status-message-BEh5HV7d.jsaround lines 280–286:When
entry.totalTokensFreshis nottrue,totalTokensfalls back tologUsage.total, whichreadRecentSessionUsageFromTranscriptcomputes bysumming
cacheReadacross multiple turns. The percentage is then computedas
total / contextWindowinformatTokens(around line 84), yieldingExpected behaviour
📚 Contextshould reflect the current request's prompt size(
inputTokens + cacheRead + cacheWriteof the latest turn), notcumulative-across-turns usage. Cumulative usage is fine to surface, but
on a separate line / with a different label, not divided by the context
window.
Repro
claude-opus-4-6(or any Anthropic model with 1M context configured).
/status— the Context line eventually exceeds 100% eventhough Compactions remains 0 and the model never errors with a
context overflow.
Related
Environment
claude-cli/claude-opus-4-6via OAuth