fix(codex): prefer native tokens for resume budget#83229
Conversation
|
Thanks for the context here. I did a careful shell check against current Current main and the shipped v2026.6.6 release already cover the central Codex stale-token resume problem with the newer startup-binding guard, token-freshness handling, and context-engine-first compaction path. This branch targets the older pre-refactor location, is now conflicting, and is no longer the right landing candidate. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the shipped v2026.6.6 startup-binding and context-engine-first compaction behavior as the canonical fix, and close this conflicting branch. Do we have a high-confidence way to reproduce the issue? Not applicable as a current-main failure: the old stale mirrored-token resume case is now covered by current startup-binding freshness checks and regression tests. The pre-fix behavior is clear from the PR diff and previous review, but current main no longer needs this branch to solve the central case. Is this the best way to solve the issue? No, this PR is no longer the best way to solve the issue. The shipped current implementation handles stale mirrored totals at the session freshness and startup-binding boundary, while this branch edits the older run-attempt location and now conflicts with main. Security review: Security review cleared: No concrete security or supply-chain concern found in the two-file Codex runtime/test diff. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against f1b8827d20c8; fix evidence: release v2026.6.6, commit 8c802aa68351. |
|
@clawsweeper re-review The Real behavior proof check is passing and the PR body includes live local runtime evidence plus the focused regression lane. Please refresh the durable review verdict against the current proof. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
ClawSweeper applied the proposed close for this PR.
|
Summary
This is the narrow follow-up for the remaining Codex app-server resume-budget edge case. Upstream
mainalready has the broader native rollout guard and dynamic tool-result cap; this patch only changes token precedence when both native rollout usage and mirrored OpenClaw session totals are present.Real behavior proof
Behavior or issue addressed: OpenClaw can keep a high mirrored session token total after Codex app-server compaction. Current
mainreads nativelast_token_usage, but still evaluates the resume guard withmax(sessionTokens, nativeTokens), so a stale mirrored total can rotate a healthy compacted native thread. This patch prefersnativeTokens ?? sessionTokens.Real environment tested: Han local OpenClaw install on macOS, OpenClaw
2026.5.16-beta.3, Gateway running against the main agent with WebChat/Codex app-server bindings.Exact steps or command run after this patch: Applied the same one-line runtime patch locally, restarted/checked OpenClaw, verified the installed runtime contains
const tokenCount = nativeTokens ?? sessionTokens;, and ran the focused app-server regression lane in this rebased PR worktree.Evidence after fix: Live terminal output from the local OpenClaw setup after the patch:
Observed result after fix: The local installed runtime now uses native Codex rollout token usage first, so a compacted native thread is not forced to rotate solely because OpenClaw mirrored session totals are stale. Gateway stayed healthy after the patch. The rebased PR regression also passed:
Test Files 1 passed (1); Tests 7 passed | 151 skipped (158).What was not tested: Full repository test suite and a live upstream CI WebChat session. The live local Gateway/runtime check and focused app-server regression were tested.
Supplemental validation
Supplemental results: oxfmt passed, git diff whitespace passed, focused Vitest passed.