Repository navigation
Description
Version: v2026.7.1 (source, branch from tag; also reproduced field-shapes on a clean npm install), Windows 11, codex agent runtime (managed app-server 0.144.3), Telegram channel.
Symptom: /status context shows ?/272k after ordinary turns, then a real number again after an auto-compaction, oscillating. Both of our agents show it since upgrading to 2026.7.1 (from 6.11, where totals displayed continuously).
Mechanism (traced): in src/agents/command/session-store.ts (~232-276), the post-run persist takes one of three branches. Ordinary codex runs arrive with per-run usage populated (inputTokens, outputTokens, cacheRead are all written — e.g. 1029/71/122624 in our store) but the aggregate usage.totalTokens missing/0, so hasUsageTotalTokens is false and the fallback branch writes totalTokensFresh: false — which /status (commands-context-report.ts:290-294) renders as ?. Only the compaction-snapshot branch (compactionTokensAfter) stamps totalTokensFresh: true, which is why the display heals at each compaction and goes stale again on the next plain turn.
Expected: ordinary codex turns should refresh the trusted total (the engine reports total_token_usage per turn — the transcript records carry correct usage.totalTokens on every assistant message, e.g. 81070/81342/85293 in our files — so the data exists at write time; it just doesn't reach the run-summary aggregate the store checks).
Repro sketch:
- codex runtime agent on 2026.7.1, any model; send a normal message.
- Read the session entry:
inputTokens/outputTokens/cacheReadpopulated,totalTokenscarried from before,totalTokensFresh: false. /status→?/N. Wait for an auto-compaction → number returns; next turn →?again.
Happy to test a patch. (Same setup as our #106403 report if environment details help.)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jul 14, 2026
Codex review: this still needs some work.
Summary
Current main contains ordinary-turn and resumed-turn usage repairs, but the maintainer’s explicit live numeric /status closeout condition remains unverified.
Reproducibility: The original release report and later repair describe a concrete failure, but no current-main failure was reproduced; inspected source and two-turn harness coverage support the repaired behavior.
Maintainer decision needed
Next step
The assignee should capture the requested supported-runtime freshness and numeric /status results, or explicitly accept the existing repair evidence for closeout.
Review details
Best possible solution:
Confirm the shipped producer-backed accounting with a supported-runtime session showing fresh numeric /status usage across successive ordinary turns.
Do we have a high-confidence way to reproduce the issue?
The original release report and later repair describe a concrete failure, but no current-main failure was reproduced; inspected source and two-turn harness coverage support the repaired behavior.
Is this the best way to solve the issue?
The existing producer-backed repair respects the distinction between lifetime billing and current prompt usage; verification is the next step rather than another speculative persistence patch.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against a08c6b39287b.
Label changes
Label changes:
No label changes.
Label justifications:
P2: The reported failure affects context visibility without establishing interrupted execution or data loss.impact:session-state: The report concerns persistence and freshness of session context accounting.impact:ux-friction: Unknown context usage makes remaining session capacity harder to judge.Evidence reviewed
What I checked:
extensions/codex/src/app-server/event-projector-usage.ts:59, a08c6b39287b)src/agents/command/session-store.ts:160, a08c6b39287b)extensions/codex/src/app-server/run-attempt.test.ts:4540, a08c6b39287b)Likely related people:
extensions/codex/src/app-server/event-projector-usage.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed October 16, 2026, 5:49 AM ET / 09:49 UTC.
fix(sessions): preserve existing totalTokens for non-CLI usage withou…
steipete commentedon Jul 16, 2026
Maintainer result: reviewed direct Codex source and all three alternatives. Closed #107622, #107630, and #107813. No OpenClaw patch landed.
Contract evidence:
total_token_usage(source).total, per-responselast, andmodelContextWindow(shape). It has no current-window field.Best fix: add an explicit current-window value to the Codex producer/protocol, then map that field to OpenClaw
contextUsage. Do not infer it from lifetime totals or downstream billing/cache buckets. Until that producer exists,/statusremains unknown.Current
mainregression proof passed: status 85 tests, session-store 54 tests, Codex event projector 153 tests (292 total). The existing tests preserve unknown for stale/cumulative-only usage and preserve a fresh compaction snapshot.Removed the queueable/fix-shape-clear labels. This is not safely queueable as an OpenClaw-only patch today. Keeping the issue open for the producer contract.
21 remaining items
fix(codex): make status context freshness truthful (openclaw#107813)
steipete commentedon Oct 24, 2026
Thanks for filing this. We're closing older issues that no longer look actionable on current
main.#107813 made Codex /status context freshness truthful by using exact per-response usage and otherwise reporting it as unknown, which removes the oscillation described here. If /status still flips on a current release, please open a fresh issue with the version and output.