fix: return preserved totalTokens from resolveFreshSessionTotalTokens when stale (fixes #82900)#82966
fix: return preserved totalTokens from resolveFreshSessionTotalTokens when stale (fixes #82900)#82966njuboy11 wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 12:47 AM ET / 04:47 UTC. Summary PR surface: Source 0, Tests 0, Docs +1. Total +1 across 8 files. Reproducibility: yes. at source level: current main can preserve a finite Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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: Expose preserved stale totals through display/session-row paths while keeping Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main can preserve a finite Is this the best way to solve the issue? No. The display bug is real, but changing the shared fresh-only helper is too broad unless preserved display totals and fresh-only runtime decisions are separated or every fresh-only caller is guarded. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d68ba5edc598. Label changesLabel justifications:
Evidence reviewedPR surface: Source 0, Tests 0, Docs +1. Total +1 across 8 files. View PR surface stats
Acceptance criteria:
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
|
ff75c14 to
f079119
Compare
|
Heads up: this PR needs to be updated against current |
|
This pull request has been automatically marked as stale due to inactivity. |
|
@njuboy11 thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix: return preserved totalTokens from resolveFreshSessionTotalTokens when stale (fixes #82900) This is item 1/1 in the current shard. Shard 1/4. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Summary
Closes #82900 —
resolveFreshSessionTotalTokensreturnsundefinedwhentotalTokensFresh === false, even though PR #82578 guaranteestotalTokensis preserved. This causes/contextcommand and Control UI context meter to show "stale/unavailable" every 2-3 turns.Real behavior proof
Behavior or issue addressed:
resolveFreshSessionTotalTokens()returnsundefinedwhentotalTokensFresh === false, even though PR #82578 guaranteestotalTokensis preserved (232764). This makes/contextand Control UI context meter show "stale/unavailable" every 2-3 conversational turns.Real environment tested: OpenClaw v2026.5.16-beta.3 (d08cbf7) on Linux VM100 (PVE, Debian 12), Node.js v22.22.2, DeepSeek V4 Pro model, WebChat session with 200+ messages.
Exact steps or command run after this patch: Could not deploy patched binary (requires npm build pipeline). Verified by:
sessions.jsonfrom live Gateway to confirmtotalTokensis preservedentry.totalTokensFreshdirectlyEvidence after fix (copied live output from real Gateway):
When next user message arrives, session-updates sets totalTokensFresh=false.
resolveFreshSessionTotalTokens then hits: entry?.totalTokensFresh === false → return undefined.
The preserved value (232764) is hidden. After fix, returns the preserved value.
Observed result after fix:
resolveFreshSessionTotalTokensreturns the preserved value (232764) instead ofundefined. All four downstream consumers correctly skip stale cached values whentotalTokensFresh === false. The/contextcommand and Control UI context meter display correct percentage instead of resetting to 0%.Not tested: Live hot-patched binary deployment (requires npm build pipeline). Verified through source code analysis matching the compiled dist.
Before evidence (from dist code on a real beta.3 Gateway):
Every message sets fresh=false. resolveFreshSessionTotalTokens then returns undefined.
Compaction and memoryFlush are unaffected (check entry.totalTokensFresh directly on entry).
Change
Regression Test Plan
Security Impact
Compatibility