openclaw - ✅(Solved) Fix Context usage mismatch causes false 'context full' warnings; stale inputTokens after compaction [1 pull requests, 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#66483Fetched 2026-04-15 06:26:02
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Root Cause

Impact\n- Users think context is still full after compaction; sessions get reset/compacted unnecessarily.\n- False alarms in long-running sessions.\n\nRoot cause\n- UI and backend use different context measurement sources.\n- UI continues showing stale inputTokens after compaction.\n\nPlanned fix\n- Align UI and backend to a single source of truth for context usage.\n- After compaction, clear/zero stale inputTokens so UI reflects real-time active usage.\n\nAcceptance criteria\n- UI displays context usage from the backend’s canonical metric (e.g., activeContextTokens + capacity).\n- After a compaction event, UI no longer shows pre-compaction inputTokens; no false "context full" warning persists.\n- Backend exposes a single canonical context usage metric and resets relevant counters on compaction.\n- Add an automated test that: (1) fills context to trigger compaction, (2) verifies post-compaction UI reflects cleared usage, (3) confirms no false warning.\n\nRepro steps\n1) Run a long session to trigger compaction.\n2) Observe UI continues to display near-full usage based on stale inputTokens.\n3) Compare with backend session status which reflects compacted state.\n\nNotes\n- Prefer publishing context:compacted events with a monotonically increasing sequence/timestamp so UI can deterministically reset/refresh.\n- If helpful, I can implement and open a PR once this issue is confirmed.

Fix Action

Fixed

PR fix notes

PR #66485: Align context usage display, refresh chat after compaction

Description (problem / solution / changelog)

  • /status context % now uses canonical totalTokens when fresh (matches chat context notice)\n- Refresh chat history on compaction completion to reflect compacted transcript and cleared token counters\n\nFixes openclaw/openclaw#66483

Changed files

  • ui/src/ui/app-gateway.ts (modified, +17/-4)
  • ui/src/ui/chat/slash-command-executor.ts (modified, +5/-1)
RAW_BUFFERClick to expand / collapse

Impact\n- Users think context is still full after compaction; sessions get reset/compacted unnecessarily.\n- False alarms in long-running sessions.\n\nRoot cause\n- UI and backend use different context measurement sources.\n- UI continues showing stale inputTokens after compaction.\n\nPlanned fix\n- Align UI and backend to a single source of truth for context usage.\n- After compaction, clear/zero stale inputTokens so UI reflects real-time active usage.\n\nAcceptance criteria\n- UI displays context usage from the backend’s canonical metric (e.g., activeContextTokens + capacity).\n- After a compaction event, UI no longer shows pre-compaction inputTokens; no false "context full" warning persists.\n- Backend exposes a single canonical context usage metric and resets relevant counters on compaction.\n- Add an automated test that: (1) fills context to trigger compaction, (2) verifies post-compaction UI reflects cleared usage, (3) confirms no false warning.\n\nRepro steps\n1) Run a long session to trigger compaction.\n2) Observe UI continues to display near-full usage based on stale inputTokens.\n3) Compare with backend session status which reflects compacted state.\n\nNotes\n- Prefer publishing context:compacted events with a monotonically increasing sequence/timestamp so UI can deterministically reset/refresh.\n- If helpful, I can implement and open a PR once this issue is confirmed.

extent analysis

TL;DR

Align the UI and backend to use a single source of truth for context usage to resolve the discrepancy in context fullness display.

Guidance

  • Verify that the UI is using the backend's canonical metric (e.g., activeContextTokens + capacity) to display context usage.
  • After a compaction event, ensure that the UI clears or zeros stale inputTokens to reflect real-time active usage.
  • Implement an automated test to fill the context, trigger compaction, and verify that the UI reflects cleared usage and does not display false warnings.
  • Consider publishing context:compacted events with a monotonically increasing sequence or timestamp to help the UI deterministically reset or refresh.

Example

No code example is provided as the issue does not contain specific code snippets or APIs.

Notes

The provided guidance assumes that the issue is primarily caused by the discrepancy between the UI and backend's context measurement sources. However, the actual implementation details may vary depending on the specific system architecture and requirements.

Recommendation

Apply the planned fix by aligning the UI and backend to a single source of truth for context usage, as this addresses the root cause of the issue and ensures consistency in context fullness display.

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 Context usage mismatch causes false 'context full' warnings; stale inputTokens after compaction [1 pull requests, 1 participants]