Repository navigation
fix(codex): tool turns lose their final answer after a transient retry - #178102
gloss-dandelion-cult wants to merge 3 commits into
Conversation
…d prompt A same-run continuation (transient retry, compaction, plugin refresh) suppresses its internal prompt, so its new native turn has no prompt identity and settled-turn capture always failed with provenance_rejected. Anchor capture on the prompt this run already persisted, keep the tool boundary bound to the active turn, and give each verifier rejection site its own diagnostic reason. Refs openclaw#155396
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR anchors Codex continuation recovery to the run’s persisted prompt and adds specific provenance rejection diagnostics. Example: A provider overload triggers a retry that runs a receipt command once, writes AMBER-731, and finishes without assistant text.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: it fixes a verified continuation-recovery defect still present on main, with no introduced correctness findings. The exact-head CI gate remains red on a failure also observed on the pinned base. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Codex plugin translates native turns into OpenClaw transcript evidence; its history verifier supplies bounded, validated context to the existing tool-free finalizer. flowchart LR
A[User request] --> B[Embedded runner]
B --> C[Native Codex retry]
C --> D[Transcript mirror]
D --> E[Settled history verifier]
E --> F[Tool free finalizer]
F --> G[Recovered answer]
Technical reviewBest possible solution: Retain this focused recorder-backed prompt handoff through the existing verifier and tool-free finalizer. Do we have a high-confidence way to reproduce the issue? The current-main suppression-to-verifier path deterministically lacks the required current-turn prompt; production transcript evidence and the contributor’s pinned-base Gateway control corroborate it, without executing target code during this review. Is this the best way to solve the issue? The patch fixes the handoff at the existing capture owner, preserves native tool identities and integrity checks, and adds no parallel recovery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3183356530eb. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +33, Tests +241. Total +274 across 8 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 24, 2026, 9:13 AM ET / 13:13 UTC (Revision 2). |
Brings in openclaw#181779, which anchors a prompt-suppressed (recorder-less) turn's settled evidence at its first mirrored row. It and this branch's continuation anchor edit the same verifier; both are kept: - settled-turn-evidence.ts: SettledTurnMessages carries both promptIdentity (a same-run continuation's persisted prompt) and promptSuppressed. The two never coexist: promptSuppressed needs no recorder, promptIdentity comes from one. The verifier keeps this branch's per-site reasons; the suppressed path gets its own two (provenance_unexpected_prompt, provenance_foreign_anchor) instead of the shared provenance_rejected this branch retired. - session-history-worker-runtime.ts: forwards both fields. - settled-turn-context.test.ts: main's restructured file, with this branch's reason assertions and continuation cases ported into its helpers, plus a foreign-anchor case for the suppressed path. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp
Adds a "same-run continuation after a transient provider overload" scenario to the native finalizer suite, on the pinned Codex app server. This is the path openclaw#155396 reported. The first native turn persists and annotates the user's prompt, then the provider fails the response as server_is_overloaded before any output. The attempt ends failed with 503 OVERLOADED, replay-safe, after one provider request. The retry keeps the recorder and suppresses the prompt (what attempt-normalization.ts sets after a persisted prompt), and runs the tool on a new native turn with no final text. Settled evidence must capture the persisted prompt, the call and its output, and the tool-free finalizer must persist one answer without repeating the command. The native fixture gains an "overload" phase. It stays scripted under the live-provider variant, so only the model's real turns go to OpenAI. With the fix reverted, the scenario fails with "Native turn lost its settled-tool evidence" (3 of 3 runs). With the fix it passes 10 of 10. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp
|
@clawsweeper re-review The head is now 🍃 frond-gloss, via Claude Code · https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp |
|
🦞👀 Re-review progress:
|
Preserve the recorder-backed original prompt when a same-run Codex continuation suppresses another prompt after a transient retry. Carry its identity through capture and worker verification so the existing tool-free finalizer can return the completed work without repeating tools. Keep the recorder-free recovery path and provenance checks intact. The continuation regressions fail on the base and pass with the fix, including real native execution with SQLite and an exactly-once command effect. The focused regressions pass again after integrating main's unrelated typecheck repair. Carries forward #178102 through a credited replacement because its organization-owned fork rejected maintainer pushes. Related: #155396; broader diagnostics remain outside this repair. Co-authored-by: gloss-dandelion-cult <[email protected]>
|
Thanks @gloss-dandelion-cult for the fix and the detailed reproduction and proof. The reviewed change landed through credited replacement #183077 as f120b9b. The organization-owned fork rejected maintainer pushes, so the replacement preserved your contributor commits and credit while carrying the focused repair through validation and landing. Closing this original PR in favor of the landed replacement. |
…183077) Preserve the recorder-backed original prompt when a same-run Codex continuation suppresses another prompt after a transient retry. Carry its identity through capture and worker verification so the existing tool-free finalizer can return the completed work without repeating tools. Keep the recorder-free recovery path and provenance checks intact. The continuation regressions fail on the base and pass with the fix, including real native execution with SQLite and an exactly-once command effect. The focused regressions pass again after integrating main's unrelated typecheck repair. Carries forward openclaw#178102 through a credited replacement because its organization-owned fork rejected maintainer pushes. Related: openclaw#155396; broader diagnostics remain outside this repair. Co-authored-by: gloss-dandelion-cult <[email protected]>
Preserve the recorder-backed original prompt when a same-run Codex continuation suppresses another prompt after a transient retry. Carry its identity through capture and worker verification so the existing tool-free finalizer can return the completed work without repeating tools. Keep the recorder-free recovery path and provenance checks intact. The continuation regressions fail on the base and pass with the fix, including real native execution with SQLite and an exactly-once command effect. The focused regressions pass again after integrating main's unrelated typecheck repair. Carries forward #178102 through a credited replacement because its organization-owned fork rejected maintainer pushes. Related: #155396; broader diagnostics remain outside this repair. Co-authored-by: gloss-dandelion-cult <[email protected]> Release adaptation: stable captures settled context at a single call site (main moved it into onSettledTurn); applied the continued-prompt evidence prefix and promptIdentity there. Ported the continuation evidence unit case to stable's captureContext; main's native overload-continuation scenario depends on main-only native fixture changes and was not ported. (cherry picked from commit f120b9b)
Closes #155396
Related: #181779 (the stranded-reply retry, which has no recorder; composes with this PR, see below)
What Problem This Solves
Fixes: a Codex tool turn delivers no final answer (
provenance_rejected→context_unavailable→ harness failure) when a transient same-model retry or another same-run continuation ran the tools on a new native turn.User Impact
User impact: channel and scheduled Codex turns that hit a provider overload, then finish their tools without a final message, now get the normal tool-free summary instead of a failed run. Settled-turn capture rejections now log which provenance check failed.
Why This Change Was Made
After a transient retry the runner suppresses the prompt it already persisted (
attempt-normalization.ts) but keeps that run's transcript recorder. So the retried native turn has no<turn>:promptidentity, while the verifier required one for the active turn. Capture now anchors on the prompt the recorder persisted on the earlier native turn. The verifier still requires that row in history, in order, with matching source evidence, and still binds the tool boundary to the active turn. Duplicate, drift, mirror-prefix and foreign-turn checks are unchanged. Each verifier rejection site now reports its own reason instead of a sharedprovenance_rejected.#181779 (merged) handles the other suppressed-prompt case: the stranded-reply retry, which has no recorder, so no prompt row exists anywhere; it anchors on the turn's first mirrored row. The two never overlap:
promptSuppressedneeds no recorder, andpromptIdentitycomes from one. Main is merged into this branch with both anchors kept. The suppressed path gets its own two reasons (provenance_unexpected_prompt,provenance_foreign_anchor) because this PR retires the sharedprovenance_rejected.Evidence
Behavior or issue addressed: #155396. A direct-channel Codex turn completes its tools after a
reason=overloadedtransient retry, ends with no final text, and fails withcapture failed reason=provenance_rejected→context is unavailable→Codex agent harness failed; not falling back.Before evidence: reproduced on main
7299b241097fin the isolated Gateway run below. It is the same log sequence as the issue, and the agent run ends withstatus: "error"and no payloads after the tool already ran once.Real environment tested: an isolated Gateway built from this branch at
11dd11cc4fb6, and the same Gateway from main7299b241097fas the control. Each had its own state dir, config and loopback port, with channels skipped and the bundled Codex plugin on the pinned native Codex app server 0.162.1 (homeScope: "agent",tools.exec.mode: "full"). Native Codex pointed at a local scripted Responses server via-c openai_base_url=…. One user message was sent withopenclaw agent --agent main --session-id … --message … --json, so it went through the full embedded runner, its transient retry and settled-turn finalization. Linux x86-64, Node 26.12.1.Exact steps or command run after this patch: the scripted provider decides from request content only:
response.failedwithserver_is_overloaded(the transient overload);exec_commandthat appendsAMBER-731to a marker file;Every model request reached that local server. There was no real model call and nothing reached a real endpoint. Commands, config and provider script are in the details below.
Evidence after fix:
11dd11cc4fb67299b241097fAMBER-731× 1AMBER-731× 1capture failed reason=provenance_rejectedstatus: "ok", payload "The receipt command ran once: AMBER-731."status: "error", payloads[]The finalizer request on this branch carried
message, message, function_call, function_call_output, message: the persisted user prompt, the retried turn's tool call and its output, then the finalizer's notice.Observed result after fix: the overloaded turn is retried once, the retried turn's tool runs exactly once, and its empty final is recovered by one tool-free finalizer turn whose answer is the run's only reply. On main the same run loses its answer after doing the work.
Native regression (pinned Codex app server, CI-runnable):
settled-turn-finalizer.native.test.ts› "same-run continuation after a transient provider overload". The first native turn persists and annotates the prompt; the provider fails it as overloaded (asserted:failed,503 OVERLOADED, replay-safe, one request). The retry keeps the recorder and suppresses the prompt; the tool runs on a new native turn with no final text. Settled evidence must hold the persisted prompt, the call and its output, and the finalizer persists one answer without repeating the command. With the fix reverted it fails 3/3 withNative turn lost its settled-tool evidence; with the fix it passes 10/10. The whole summary suite passes 7/7. A live-provider variant runs underOPENCLAW_LIVE_CODEX_SETTLED_FINALIZATION=1, with the overload still scripted.Unit coverage:
settled-turn-context.test.tsasserts the specific reason at every fail-closed site. It also covers continuation capture against the persisted prompt, a continuation whose persisted prompt is missing from history (rejected), and #181779's suppressed path, including the two new reasons.Checks at
11dd11cc4fb6:pnpm tsgo:extensions; vitest over 24 files that touch the verifier, capture, history-rejection, worker runtime or the finalizer (313 tests); oxlint,oxfmt --checkand the line-cap ratchet on the 8 changed files. All pass.What was not tested: a live provider. My account has no OpenAI key on this host, so the model replies are scripted (only the overload is scripted in the live variant, which I have not run). I also did not test a real chat channel (Telegram/Discord); delivery here is the
openclaw agentresult.Redacted Gateway logs
This branch:
main:
Provider phases, in order (this branch):
overloaded→tool-call→empty-final-after-tool→finalizer-summary. On main: the first three only.Run recipe
The provider answers
GET /v1/responseswith 426, andPOST /v1/responseswith SSE (response.created, thenresponse.output_item.donewhen there is an item, thenresponse.completedorresponse.failed), choosing the phase as in steps 1–4 above.🍃 frond-gloss, via Claude Code · https://claude.ai/code/session_01PiKbtQbHKKfq82arnmwBYp