fix(agents): scope stale usage clearing to pre-compaction messages only [AI-assisted]#91468
fix(agents): scope stale usage clearing to pre-compaction messages only [AI-assisted]#91468425072024 wants to merge 5 commits into
Conversation
clearStaleAssistantUsageOnSessionMessages unconditionally zeroed usage on *all* assistant messages after every compaction. This broke the context token counter in the TUI because new assistant messages with valid usage from fresh LLM responses were also zeroed. Store the pre-compaction message count in handleCompactionStart and only clear usage on messages that existed before the compaction. Messages added during or after compaction retain their valid usage. Fixes openclaw#50795
|
Codex review: needs real behavior proof before merge. Reviewed June 9, 2026, 5:34 AM ET / 09:34 UTC. Summary PR surface: Source +87. Total +87 across 2 files. Reproducibility: yes. from source inspection: current main clears every assistant usage snapshot on non-retry compaction end, and the linked report describes the visible counter consequence. I did not run a live TUI/gateway reproduction in this read-only review. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a refreshed version that preserves fresh post-compaction assistant usage, keeps stale pre-compaction snapshots zeroed, and includes both focused regression coverage and redacted real counter proof. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main clears every assistant usage snapshot on non-retry compaction end, and the linked report describes the visible counter consequence. I did not run a live TUI/gateway reproduction in this read-only review. Is this the best way to solve the issue? Yes, with validation gaps: the object-reference boundary is a narrow fix because current compaction rebuilds the message array from retained message objects and the agent setter only copies the top-level array. It still needs regression coverage and real behavior proof before it is the best mergeable version. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 5e1fbca3cbc6. Label changesLabel justifications:
Evidence reviewedPR surface: Source +87. Total +87 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
🔧 修复说明 (Addressing ClawSweeper P1 feedback)问题:index-based boundary 在 compaction 重写后不可靠原 PR 使用 修复:改用 object-identity Set将
为什么 object-identity 是安全的:
修改文件
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
🔄 All P1 Fixes Complete
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Summary
0/1.0m (0%)even after successful LLM responses. Issue Bug: Context token count always shows 0 after compaction #50795.clearStaleAssistantUsageOnSessionMessagesunconditionally zeros usage on all assistant messages after every successful compaction. Post-compaction messages with valid usage are reset alongside stale pre-compaction messages.preCompactionAssistantMessages: Set<object>) captured inhandleCompactionStart. InclearStaleAssistantUsageOnSessionMessages, only zero usage for messages whose references exist in the Set. New messages are excluded.session.messages, invalidating indices. Object references survive rewrites — retained messages keep their identity, new messages have distinct references.Verification
Fixes #50795