Summary
The "Context" line in the TUI and /status output reports cumulative
session token usage divided by the model's context window, producing
nonsensical percentages like 2.3m/1.0m (228%) even with Compactions: 0
and 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-*.js path used by TUI and channel status cards.
Example status output
🦞 OpenClaw 2026.5.12 (f066dd2)
🧠 Model: claude-cli/claude-opus-4-6 · 🔑 oauth (anthropic:claude-cli)
🧮 Tokens: 16 in / 5.1k out
🗄️ Cache: 100% hit · 2.3m cached, 11k new
📚 Context: 2.3m/1.0m (228%) · 🧹 Compactions: 0
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: 0 confirms the actual context never overflowed
(Anthropic would have rejected the request otherwise).
Root cause (dist code reference)
In dist/status-message-BEh5HV7d.js around lines 280–286:
let totalTokens = freshTotalTokens ?? (... ?? entry?.totalTokens ?? ...);
if (args.includeTranscriptUsage) {
const logUsage = readRecentSessionUsageFromTranscript(...);
if (logUsage) {
const candidate = logUsage.promptTokens || logUsage.total;
if (allowTranscriptContextUsage && (!totalTokens || candidate > totalTokens))
totalTokens = candidate;
When entry.totalTokensFresh is not true, totalTokens falls back to
logUsage.total, which readRecentSessionUsageFromTranscript computes by
summing cacheRead across multiple turns. The percentage is then computed
as total / contextWindow in formatTokens (around line 84), yielding
100% for long sessions with heavy cache reuse.
Expected behaviour
📚 Context should reflect the current request's prompt size
(inputTokens + cacheRead + cacheWrite of the latest turn), not
cumulative-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
- Start a Claude Code (or claude-cli) session with
claude-opus-4-6
(or any Anthropic model with 1M context configured).
- Run a long session with many turns using prompt caching.
- Observe
/status — the Context line eventually exceeds 100% even
though Compactions remains 0 and the model never errors with a
context overflow.
Related
Environment
- OpenClaw 2026.5.12 (f066dd2)
- Runtime: Claude CLI
- Model:
claude-cli/claude-opus-4-6 via OAuth
- Surface: TUI status card
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