openclaw - ✅(Solved) Fix status: Context line shows pre-compaction size instead of current context [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#72140Fetched 2026-04-27 05:34:20
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #72285: Status: show post-compaction context tokens when totals are stale

Description (problem / solution / changelog)

## Summary

  • Fix status context reporting to prefer fresh totals and fall back to the latest compaction checkpoint tokensAfter when session totals are marked stale.
  • Keep context usage output aligned with post-compaction state so users do not see pre-compaction token counts.
  • Add a regression test that reproduces stale totalTokens after compaction and verifies status shows the checkpoint post-compaction size.

Test plan

  • pnpm test src/auto-reply/status.test.ts -t "uses latest compaction checkpoint tokens when total tokens are stale"

Changed files

  • src/auto-reply/status.test.ts (modified, +38/-0)
  • src/status/status-message.ts (modified, +33/-1)

Code Example

⚙️ Compacted (106k → 36)Context 36/200k (0%)

---

🧮 Tokens: 6 in / 124 out
📚 Context: 76k/200k (38%) · 🧹 Compactions: 1

---

📚 Context: 36/200k (0%)
🧹 Compactions: 1 (last: 106k → 36)
RAW_BUFFERClick to expand / collapse

Bug

After an auto-compaction, /status (and the post-message status card) shows the pre-compaction context size on the "Context" line, not the current size.

Example

⚙️ Compacted (106k → 36) • Context 36/200k (0%)

then on the next status:

🧮 Tokens: 6 in / 124 out
📚 Context: 76k/200k (38%) · 🧹 Compactions: 1

The 76k / 106k figures shown immediately after compaction are stale — they reflect what was in context right before compaction fired, not what's actually there now (which is the summary, ~a few hundred to a few thousand tokens).

This is misleading: users read "Context: 106k/200k (53%)" and think compaction didn't work.

Expected

The "Context" field should reflect the current post-compaction context size.

The pre-compaction peak is useful but belongs on the Compactions line as a delta, e.g.:

📚 Context: 36/200k (0%)
🧹 Compactions: 1 (last: 106k → 36)

Repro

  1. Let a session grow to >100k tokens.
  2. Trigger /compact or auto-compact.
  3. Run /status — observe Context line still shows pre-compaction figure until the next user turn refreshes it.

Notes

  • Reported in WhatsApp group surface, but the status card formatter is shared, so this affects all channels.
  • Likely a stale read of the context window snapshot taken before the compaction summary replaces history.

extent analysis

TL;DR

Update the context size calculation to reflect the post-compaction size, rather than relying on a stale pre-compaction snapshot.

Guidance

  • Review the code responsible for updating the context size and ensure it is using the latest post-compaction values.
  • Verify that the compaction process is correctly updating the context window snapshot after replacing the history.
  • Consider adding a delta to the Compactions line to display the pre-compaction peak, as suggested in the Expected section.
  • Investigate the timing of when the context size is calculated and displayed to ensure it is not being cached or updated incorrectly.

Example

No code snippet is provided as the issue does not include specific code references.

Notes

The issue appears to be related to a stale read of the context window snapshot, but without more information about the underlying code, it is difficult to provide a more specific solution.

Recommendation

Apply a workaround to update the context size calculation to reflect the post-compaction size, as this is likely to be a more straightforward fix than rewriting the compaction process.

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 status: Context line shows pre-compaction size instead of current context [1 pull requests, 1 participants]