openclaw - 💡(How to fix) Fix Control UI: subagent context badge can show historical total tokens as current context usage [1 comments, 1 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#59345Fetched 2026-04-08 02:25:42
View on GitHub
Comments
1
Participants
1
Timeline
1
Reactions
0
Timeline (top)
commented ×1

The Control UI subagent/session badge can show impossible values such as:

  • 100% context used 468.2k / 48k

This appears to be a UI/display bug, not a real live-context overflow.

Error Message

In a real subagent thread, the UI displayed:

  • 100% context used 468.2k / 48k

Root Cause

The badge label implies current context pressure, but the displayed numerator can come from accumulated historical message.usage.totalTokens while the denominator comes from current contextTokens.

That creates a misleading state where:

  • operators may think a live subagent is far beyond its context window,
  • users may misdiagnose failures as context exhaustion,
  • historical token/cost totals get misread as active context usage.

Fix Action

Fix / Workaround

Local mitigation tested

A local bundled-asset patch changed the guard to require explicit freshness:

Notes

This was observed and locally documented on 2026-04-02. A local workaround was applied only at the bundled asset level, so a source-level fix would still be preferable.

Code Example

if (e?.totalTokensFresh === !1) return u;

---

if (e?.totalTokensFresh !== !0) return u;
RAW_BUFFERClick to expand / collapse

Control UI: subagent context badge can display historical total tokens as current context usage

Summary

The Control UI subagent/session badge can show impossible values such as:

  • 100% context used 468.2k / 48k

This appears to be a UI/display bug, not a real live-context overflow.

Why this matters

The badge label implies current context pressure, but the displayed numerator can come from accumulated historical message.usage.totalTokens while the denominator comes from current contextTokens.

That creates a misleading state where:

  • operators may think a live subagent is far beyond its context window,
  • users may misdiagnose failures as context exhaustion,
  • historical token/cost totals get misread as active context usage.

Observed behavior

In a real subagent thread, the UI displayed:

  • 100% context used 468.2k / 48k

However:

  • live active context was only in the tens of thousands of tokens,
  • 468.2k matched historical accumulated message.usage.totalTokens,
  • 48k matched the session context window,
  • the label still said context used.

Suspected root cause

The UI appears to mix two different concepts:

  • totalTokens: historical/accumulated usage
  • contextTokens: current context window usage/capacity display

Additionally, the freshness gate was too permissive:

if (e?.totalTokensFresh === !1) return u;

This means the badge was hidden only when freshness was explicitly false, but could still render when freshness was unknown/stale rather than strictly confirmed.

Local mitigation tested

A local bundled-asset patch changed the guard to require explicit freshness:

if (e?.totalTokensFresh !== !0) return u;

After that change, stale/unknown totals no longer rendered as current context usage.

Expected behavior

One of these should happen:

  1. The context used badge should render only from current context-specific metrics.
  2. If the numerator is historical total usage, the label should clearly say total/historical usage rather than context used.
  3. If freshness is not explicitly confirmed, the badge should not present the value as live current context.

Minimal reproduction idea

  1. Run a subagent/thread long enough to accumulate large historical token totals across many messages.
  2. Reopen or inspect the session in Control UI.
  3. Observe whether the badge shows a very large numerator under context used, potentially larger than the configured context window.

Impact

  • misleading operator telemetry
  • false diagnosis of context-window exhaustion
  • confusion between live context pressure and cumulative token spend/history

Notes

This was observed and locally documented on 2026-04-02. A local workaround was applied only at the bundled asset level, so a source-level fix would still be preferable.

extent analysis

TL;DR

The most likely fix is to update the freshness check to require explicit confirmation before rendering the context used badge with historical total tokens.

Guidance

  • Verify that the issue is caused by the freshness gate being too permissive by checking the totalTokensFresh value in the code.
  • Update the guard to require explicit freshness confirmation, as shown in the local mitigation test: if (e?.totalTokensFresh !== !0) return u;.
  • Consider adding a clear label to distinguish between historical total usage and current context usage to avoid confusion.
  • Test the fix by running a subagent/thread long enough to accumulate large historical token totals and verifying that the badge no longer shows incorrect values.

Example

The local mitigation test used the following code change:

if (e?.totalTokensFresh !== !0) return u;

This change ensures that the badge is only rendered when the freshness is explicitly confirmed.

Notes

The issue is specific to the Control UI subagent/session badge and may not affect other parts of the system. The local workaround was applied only at the bundled asset level, so a source-level fix is still necessary.

Recommendation

Apply the workaround by updating the freshness check to require explicit confirmation, as this will prevent the misleading display of historical total tokens as current context usage.

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

One of these should happen:

  1. The context used badge should render only from current context-specific metrics.
  2. If the numerator is historical total usage, the label should clearly say total/historical usage rather than context used.
  3. If freshness is not explicitly confirmed, the badge should not present the value as live current context.

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 - 💡(How to fix) Fix Control UI: subagent context badge can show historical total tokens as current context usage [1 comments, 1 participants]