openclaw - ✅(Solved) Fix [Bug]: /status shows Context: ?/1.0m on claude-cli runtime instead of live usage [1 pull requests, 2 comments, 3 participants]

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…
GitHub stats
openclaw/openclaw#78194Fetched 2026-05-06 06:16:02
View on GitHub
Comments
2
Participants
3
Timeline
4
Reactions
2
Author
Timeline (top)
commented ×2cross-referenced ×2

When the active runtime is claude-cli (Anthropic via the Claude CLI backend, oauth or otherwise), /status / session_status shows Context: ?/1.0m instead of real usage numbers. The context window limit is detected correctly (1.0m for Opus 4.7), but live usage cannot be read off this runtime path.

This is a regression — the same configuration previously showed live context usage on claude-cli.

Root Cause

When the active runtime is claude-cli (Anthropic via the Claude CLI backend, oauth or otherwise), /status / session_status shows Context: ?/1.0m instead of real usage numbers. The context window limit is detected correctly (1.0m for Opus 4.7), but live usage cannot be read off this runtime path.

This is a regression — the same configuration previously showed live context usage on claude-cli.

PR fix notes

PR #78239: fix: restore /status context usage for Claude CLI (#78194)

Description (problem / solution / changelog)

Summary

Restores live Context: usage in /status and session_status for CLI backends (e.g. claude-cli) by persisting SessionEntry.totalTokens from the same last-call usage snapshot used elsewhere, instead of leaving it unset while token and cache lines still update.

Root cause

updateSessionStoreAfterAgentRun cleared usage for CLI providers when deriving totalTokens (to avoid treating cumulative run usage as prompt size), but never consumed agentMeta.lastCallUsage. Without promptTokens, deriveSessionTotalTokens returned nothing, so totalTokens / totalTokensFresh stayed wrong and the status formatter showed Context: ?/… while cache counters still reflected telemetry.

Linked issue

Fixes #78194.

Why this is safe

  • No change to auth, OAuth, model routing, or gateway policy. Display and session-store fields only.
  • CLI backends still do not use cumulative usage for context size unless lastCallUsage (or promptTokens) is present—the same guard as persistSessionUsageUpdate.
  • Synthetic “cumulative CLI usage without lastCallUsage” behavior from existing tests remains: totalTokens stays unset in that case.

Security / runtime controls (unchanged)

  • Tool/sandbox/approval paths and provider credentials are untouched.
  • Only session persistence of token display metadata is adjusted; no new data leaves the host beyond what usage already contained.

Tests run

  • git diff --check
  • pnpm vitest run src/agents/command/session-store.test.ts
  • pnpm check:changed

Real behavior proof

Not run against a live Claude CLI OAuth session in this environment. Please confirm on a real claude-cli session that /status shows a numeric context numerator (e.g. ~50k/1.0m) after at least one turn with usage, matching cache/token lines.

Out of scope

  • Changing transcript / totalTokensFresh merge rules in buildStatusMessage.
  • Broader refactors of CLI usage aggregation across other call sites.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/cli-runner.ts (modified, +1/-0)
  • src/agents/command/session-store.test.ts (modified, +60/-0)
  • src/agents/command/session-store.ts (modified, +6/-1)

Code Example

📚 Context: ?/1.0m · 🧹 Compactions: 0
🧮 Tokens: 6 in / 25 out
🗄️ Cache: 99% hit · 50k cached, 621 new
RAW_BUFFERClick to expand / collapse

Description

When the active runtime is claude-cli (Anthropic via the Claude CLI backend, oauth or otherwise), /status / session_status shows Context: ?/1.0m instead of real usage numbers. The context window limit is detected correctly (1.0m for Opus 4.7), but live usage cannot be read off this runtime path.

This is a regression — the same configuration previously showed live context usage on claude-cli.

Environment

  • OpenClaw 2026.5.4 (325df3e)
  • Model: anthropic/claude-opus-4-7
  • Runtime: Claude CLI
  • Auth: oauth (anthropic:claude-cli)
  • Selected anthropic-via-claude-cli explicitly (not a fallback artifact — same behavior occurs on the deliberate selection)

Repro

  1. Configure a session to run anthropic/claude-opus-4-7 via the claude-cli runtime
  2. Run /status (or session_status) on a session with non-trivial usage

Observed

📚 Context: ?/1.0m · 🧹 Compactions: 0
🧮 Tokens: 6 in / 25 out
🗄️ Cache: 99% hit · 50k cached, 621 new

The cache line confirms ~50k tokens in context, but the Context: field renders ? instead of ~50k/1.0m.

Expected

Context: field should reflect live usage (e.g. 50k/1.0m (5%)), as it did in earlier OpenClaw versions on this same runtime.

Notes

  • Limit detection (1.0m) works — only live-usage read is broken
  • Token in/out and cache stats render fine, so the underlying telemetry exists; appears to be a wiring gap between the claude-cli runtime stats and the Context: formatter

extent analysis

TL;DR

The issue can be resolved by investigating and fixing the wiring gap between the claude-cli runtime stats and the Context: formatter.

Guidance

  • Verify that the claude-cli runtime is correctly configured and that the telemetry data is being collected and sent to the correct endpoint.
  • Check the code that formats the Context: field to ensure it is correctly reading the live usage data from the claude-cli runtime stats.
  • Investigate the changes made in the OpenClaw version 2026.5.4 to see if there were any changes that could have caused this regression.
  • Test the Context: field with different models and runtimes to see if the issue is specific to the anthropic/claude-opus-4-7 model or the claude-cli runtime.

Example

No code snippet is provided as the issue does not contain enough information to create a specific example.

Notes

The issue seems to be specific to the claude-cli runtime and the anthropic/claude-opus-4-7 model, and it is a regression from a previous version of OpenClaw. The limit detection and token in/out and cache stats are working correctly, which suggests that the issue is with the wiring gap between the claude-cli runtime stats and the Context: formatter.

Recommendation

Apply workaround: Investigate and fix the wiring gap between the claude-cli runtime stats and the Context: formatter, as this seems to be the root cause of the issue.

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

openclaw - ✅(Solved) Fix [Bug]: /status shows Context: ?/1.0m on claude-cli runtime instead of live usage [1 pull requests, 2 comments, 3 participants]