openclaw - ✅(Solved) Fix [Bug]: Control UI token usage shows N/A, usage page missing token counts, and auto-compression fails after 2026.4.9 [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

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#65210Fetched 2026-04-12 13:25:05
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

OpenClaw fails to parse the usage field from API responses, causing token counts to display as N/A across the Control UI, the usage page to omit token statistics, and the auto-compression mechanism to fail — resulting in context overflow.

Root Cause

This is a regression: last known good version is prior to 2026.4.9, first known bad version is 2026.4.9, and the issue persists through 2026.4.11. The root cause appears to be that OpenClaw cannot correctly parse the usage field from API responses, which cascades into token display failure and auto-compression breakdown. Related issue #50196 described a different symptom (wrong calculation: "510.4k/128k") rather than "unknown/N/A" values, suggesting a distinct root cause or a new regression starting from 2026.4.9.

Fix Action

Fix / Workaround

  • Usage page: Only message counts are displayed; token consumption statistics are entirely missing. Previous versions included correct token usage records.

  • API parsing failure: The upstream API response includes a standard-compliant usage field, but OpenClaw appears unable to correctly parse it.

  • Auto-compression failure: The automatic context compression mechanism does not trigger, leading to context overflow when the context window is exceeded.

  • Manual compression workaround: After manually triggering compression, token usage temporarily displays correctly, but immediately reverts to N/A upon the next chat message.

  • Affected users: Maybe all users running OpenClaw 2026.4.9+ with local LM Studio models; multiple sessions show the same pattern, indicating it is not session-specific.

  • Severity: Blocks workflow — auto-compression failure causes context overflow, which can interrupt or lose ongoing sessions. Token monitoring is completely unavailable.

  • Frequency: Always — every session consistently fails to display token usage and auto-compression never triggers.

  • Consequence: Context overflow causes session failures and potential data loss; users cannot monitor or manage context window consumption; manual compression is only a temporary workaround.

PR fix notes

PR #65237: fix: preserve zero-valued usage fields

Description (problem / solution / changelog)

Summary

Use nullish coalescing (??) instead of logical OR (||) when serializing usage totals to NormalizedUsage.

Root Cause

When API returns input_tokens: 0 with cached_tokens: 262000:

  1. normalizeUsage produces { input: 0, cacheRead: 262000, total: 262000 }
  2. But || undefined converts 0 to undefined
  3. deriveSessionTotalTokens receives { input: undefined, cacheRead: 262000 }
  4. undefined + 262000 = NaN fails validity check
  5. totalTokensFresh = false cascades to: Sessions view shows 'unknown', auto-compression fails

Changes

  • src/agents/pi-embedded-subscribe.ts: getUsageTotals - use ?? instead of ||
  • src/agents/pi-embedded-runner/usage-accumulator.ts: toNormalizedUsage, toLastCallUsage - use ?? instead of ||
  • src/agents/pi-embedded-runner/usage-accumulator.test.ts: Updated test expectations

Fixes #65210

Changed files

  • src/agents/pi-embedded-runner/usage-accumulator.test.ts (modified, +5/-5)
  • src/agents/pi-embedded-runner/usage-accumulator.ts (modified, +10/-10)
  • src/agents/pi-embedded-subscribe.ts (modified, +4/-4)
  • src/commands/doctor-gateway-health.ts (modified, +2/-4)

Code Example

│ agent:main:main                  │ direct │ 1m ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%│ agent:main:dreaming-narrative…  │ direct │ 2h ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%
---

1. `openclaw status` output showing all sessions with "unknown/262k (?%)":


│ agent:main:main                  │ direct │ 1m ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%│ agent:main:dreaming-narrative…  │ direct │ 2h ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%

2. Control UI web Sessions page: Tokens column displays "N/A" (不适用).
3. Control UI Usage page: Only message counts shown; token statistics absent.
4. Manual compression temporarily restores token display, but it reverts to N/A after the next message.
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

OpenClaw fails to parse the usage field from API responses, causing token counts to display as N/A across the Control UI, the usage page to omit token statistics, and the auto-compression mechanism to fail — resulting in context overflow.

Steps to reproduce

  1. Update OpenClaw to version 2026.4.9 or later (up to 2026.4.11)
  2. Open Control UI (http://127.0.0.1:18789/)
  3. Navigate to Sessions view — observe the "Tokens" column shows N/A
  4. Navigate to Usage page — observe only message counts are tracked, token counts are missing
  5. Continue chatting in a session until context window is exceeded — observe auto-compression does not trigger and context overflow occurs

Expected behavior

  • Token usage should display actual consumed token counts and percentages (e.g., "10.5k/262k (4%)"), as observed in versions prior to 2026.4.9 which showed correct usage statistics.
  • The Usage page should include token consumption statistics alongside message counts.
  • Auto-compression should trigger when context window approaches capacity, preventing context overflow.

Actual behavior

  • Sessions view: Tokens column displays "unknown/262k (?%)" — the consumed token count shows "unknown", the percentage shows a question mark, and only the context window size (262k) appears correctly. On the web UI, tokens show as "N/A" (不适用).
│ agent:main:main                  │ direct │ 1m ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%   │
│ agent:main:dreaming-narrative…  │ direct │ 2h ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%   │
  • Usage page: Only message counts are displayed; token consumption statistics are entirely missing. Previous versions included correct token usage records.
  • API parsing failure: The upstream API response includes a standard-compliant usage field, but OpenClaw appears unable to correctly parse it.
  • Auto-compression failure: The automatic context compression mechanism does not trigger, leading to context overflow when the context window is exceeded.
  • Manual compression workaround: After manually triggering compression, token usage temporarily displays correctly, but immediately reverts to N/A upon the next chat message.

OpenClaw version

2026.4.9 (first affected) — 2026.4.11 (still affected)

Operating system

macOS 26.4.1 (arm64)

Install method

npm-global

Model

mlx-qwopus3.5-27b-v3

Provider / routing chain

openclaw -> lmstudio (local)

Additional provider/model setup details

Local model served via LM Studio; Node v25.9.0. with oprnai-compatible node

Logs, screenshots, and evidence

1. `openclaw status` output showing all sessions with "unknown/262k (?%)":


│ agent:main:main                  │ direct │ 1m ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%   │
│ agent:main:dreaming-narrative…  │ direct │ 2h ago  │ mlx-qwopus3.5-27b-v3 │ unknown/262k (?)%   │


2. Control UI web Sessions page: Tokens column displays "N/A" (不适用).
3. Control UI Usage page: Only message counts shown; token statistics absent.
4. Manual compression temporarily restores token display, but it reverts to N/A after the next message.

Impact and severity

  • Affected users: Maybe all users running OpenClaw 2026.4.9+ with local LM Studio models; multiple sessions show the same pattern, indicating it is not session-specific.
  • Severity: Blocks workflow — auto-compression failure causes context overflow, which can interrupt or lose ongoing sessions. Token monitoring is completely unavailable.
  • Frequency: Always — every session consistently fails to display token usage and auto-compression never triggers.
  • Consequence: Context overflow causes session failures and potential data loss; users cannot monitor or manage context window consumption; manual compression is only a temporary workaround.

Additional information

This is a regression: last known good version is prior to 2026.4.9, first known bad version is 2026.4.9, and the issue persists through 2026.4.11. The root cause appears to be that OpenClaw cannot correctly parse the usage field from API responses, which cascades into token display failure and auto-compression breakdown. Related issue #50196 described a different symptom (wrong calculation: "510.4k/128k") rather than "unknown/N/A" values, suggesting a distinct root cause or a new regression starting from 2026.4.9.

extent analysis

TL;DR

The most likely fix involves updating the OpenClaw API response parsing logic to correctly handle the usage field, potentially by reverting changes introduced in version 2026.4.9 or later.

Guidance

  1. Review API response parsing: Investigate how OpenClaw parses the usage field from API responses, focusing on changes made between versions prior to 2026.4.9 and 2026.4.9 or later.
  2. Compare with previous versions: Analyze the parsing logic in the last known good version (prior to 2026.4.9) and compare it with the current parsing logic to identify potential regressions.
  3. Test with manual compression: Utilize the manual compression workaround to temporarily restore token display and observe if the issue persists after the next chat message, helping to isolate the problem.
  4. Verify API response format: Confirm that the upstream API response includes a standard-compliant usage field and that its format has not changed, which could affect OpenClaw's parsing ability.

Example

No specific code snippet can be provided without access to OpenClaw's source code, but the investigation should focus on the API response handling and parsing logic related to the usage field.

Notes

The exact fix may require detailed knowledge of OpenClaw's internal workings and the specific changes introduced in version 2026.4.9. The provided guidance is based on the information given and may need to be adapted based on the actual code and implementation details.

Recommendation

Apply a workaround by reverting to a version prior to 2026.4.9 until a proper fix is available, as the current issue significantly impacts workflow and data integrity.

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…

FAQ

Expected behavior

  • Token usage should display actual consumed token counts and percentages (e.g., "10.5k/262k (4%)"), as observed in versions prior to 2026.4.9 which showed correct usage statistics.
  • The Usage page should include token consumption statistics alongside message counts.
  • Auto-compression should trigger when context window approaches capacity, preventing context overflow.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING