Repository navigation
fix(codex): finalize settled turns whose prompt was never mirrored - #181779
Conversation
A stranded-reply retry after a message_tool_only final is an internal system turn: prompt persistence is suppressed and it carries no transcript recorder, so the Codex harness writes no <turn>:prompt row. When that retry ends with completed tool work and no assistant text, the settled-turn verifier still required <turn>:prompt and rejected the evidence as provenance_rejected, so the tool-free recovery answer was never produced and the user got the missing-reply notice. The harness now tells the verifier when a turn mirrored no prompt, and the verifier anchors that turn's evidence at its first mirrored row. The user turn that produced the retry stays prior context; turns that mirrored a prompt are verified exactly as before, and a suppressed-prompt turn that carries a prompt row is rejected. Closes openclaw#181226
…lizer answer The stranded-reply retry finalizes in message_tool_only mode with the harness-captured context. Pin the host contract that a real finalizer answer is marked to cross source-reply suppression and that an empty finalization leaves no visible text or deliverable payload behind.
|
🦞👀 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 changesAllow Codex final-answer recovery for internal turns that intentionally persisted no prompt. Example: A Telegram user asks “What is 7 times 8?” and the delivery retry completes a tool call without returning text.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a current Codex recovery failure while preserving verification of mirrored evidence; no introduced correctness defect was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Codex plugin mirrors native turns into session history, verifies settled tool evidence, and supplies that evidence to the host’s tool-free finalizer and reply delivery. flowchart LR
A[Private final] --> B[Internal delivery retry]
B --> C[Codex native turn]
C --> D[Transcript mirror]
D --> E[Settled evidence verifier]
E --> F[Tool-free finalizer]
F --> G[Channel reply]
Technical reviewBest possible solution: Keep the existing verification and finalization owners, distinguish intentionally absent prompts explicitly, and retain exact evidence checks without replaying completed actions. Do we have a high-confidence way to reproduce the issue? Current source deterministically omits the retry’s prompt and then requires its identity during verification; contributor base/head Gateway traces corroborate the failure, without target-code execution during this review. Is this the best way to solve the issue? This is a focused repair at the existing evidence owner: the internal flag reflects actual persistence behavior, preserves ordinary prompt checks, and introduces no alternate recovery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against adb8920e42e5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +14, Tests +162, Docs +5. Total +181 across 9 files. Added test files: 0. View PR surface stats
Review metrics
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 HistoryReviewed October 23, 2026, 3:47 PM ET / 19:47 UTC (Revision 3). |
…app server Adds a prompt-less stranded-reply retry scenario to the native settled-turn finalizer proof: the real Codex app server runs one shell command, the turn ends with no assistant text and no mirrored prompt, and the finalizer persists one answer without repeating the action. Red on the base (the turn loses its settled evidence), green with the fix; the live-provider variant runs the same path against a real OpenAI model.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
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
…penclaw#181779) Recorder-free delivery retries deliberately omit a prompt row. Anchor their settled-turn evidence at the first mirrored row so Codex source-reply finalization retains prior context and completed tool evidence. Keep existing identity, payload, ordering, uniqueness, and tool-boundary verification for all turns. Related: openclaw#181226 (the provenance_rejected path). The report's separate field_limit incident remains tracked by openclaw#164191. Validation: contributor base/head regression, native finalizer, and isolated Gateway/Telegram live proof are recorded in the PR. Exact-head CI run 40059895146 passed 36 jobs. Landed under the authorized inherited-failure exception: the suite-coverage assertion in test/vitest-projects-config.test.ts:288, missing scripts/control-ui-retention/dependency-retention.test.ts, matches scheduled main run 40058965760 exactly; its aggregate CI gate also failed. CI remains red, and security-fast passed independently. Co-authored-by: Sukhdeep Johar <[email protected]>
…181779) Recorder-free delivery retries deliberately omit a prompt row. Anchor their settled-turn evidence at the first mirrored row so Codex source-reply finalization retains prior context and completed tool evidence. Keep existing identity, payload, ordering, uniqueness, and tool-boundary verification for all turns. Related: #181226 (the provenance_rejected path). The report's separate field_limit incident remains tracked by #164191. Validation: contributor base/head regression, native finalizer, and isolated Gateway/Telegram live proof are recorded in the PR. Exact-head CI run 40059895146 passed 36 jobs. Landed under the authorized inherited-failure exception: the suite-coverage assertion in test/vitest-projects-config.test.ts:288, missing scripts/control-ui-retention/dependency-retention.test.ts, matches scheduled main run 40058965760 exactly; its aggregate CI gate also failed. CI remains red, and security-fast passed independently. Co-authored-by: Sukhdeep Johar <[email protected]> Release adaptation: stable passes promptSuppressed at the single settled-context capture site (main moved it into onSettledTurn). Ported the evidence unit cases and the stranded-retry run-attempt case onto stable's harness (red without the finalize hunk). Dropped the host message_tool_only test (deliverDespiteSourceReplySuppression is main-only) and the native finalizer scenario (main-only fixture). (cherry picked from commit 7c374d4)
Backport the upstream provenance-safe promptless finalization repair for the 2026.10.10 release candidate. Co-authored-by: RomneyDa <[email protected]>
Related: #181226 (
provenance_rejectedpath). The report's separatefield_limitincident is tracked in #164191 and is not changed here.What Problem This Solves
Fixes: a Codex turn that mirrors no prompt can never capture settled-turn finalization context, so the host's tool-free recovery answer is never produced for it.
The stranded-reply retry (
src/auto-reply/reply/stranded-reply-recovery.ts) runs after amessage_tool_onlyfinal that skipped the delivery tool. It is an internal system turn:suppressNextUserMessagePersistence: trueand nouserTurnTranscriptRecorder, so the Codex harness writes no<turn>:promptrow (promptSnapshotreturns nothing, and the turn-start mirror returns early). When that retry ends with completed tool work and no assistant text, the settled-turn verifier inextensions/codex/src/app-server/settled-turn-evidence.tsstill requires<turn>:promptamong the settled identities and rejects the evidence withprovenance_rejected. The finalizer then throws "Codex settled-turn finalization context is unavailable", the harness refuses the embedded fallback, and the user gets the missing-reply notice instead of an answer. That is the sequence in the reporter's logs:message-tool-onlyoutcome,capture failed reason=provenance_rejected,context is unavailable, harness failed.User Impact
User impact: a Telegram (or any channel) direct message whose Codex-backed agent produced a private final and then ran its delivery retry without a visible answer now gets the settled-turn recovery answer instead of a delivery-failure notice. Turns that mirror a prompt are verified exactly as before: every existing rejection (missing prompt, missing tool call, duplicate identity, foreign boundary, payload drift, reordering, incomplete history) still fails closed.
Why This Change Was Made
The verifier's job is to prove that the finalizer's evidence is exactly the rows this run mirrored, in order, through this turn's tool boundary. For a turn that persisted no prompt there is no prompt row to prove. The harness now says so explicitly (
promptSuppressed, true only when persistence was suppressed and no recorder exists), and the verifier anchors that turn's evidence at its first mirrored row instead of at<turn>:prompt. The user turn that produced the retry stays in prior context, where the existing bounded-history rules apply; it is never borrowed as the retry's prompt, and no provenance check is relaxed for turns that did mirror a prompt. A suppressed-prompt turn whose evidence nevertheless carries a prompt row is rejected.Same-run continuations that keep their recorder (transient provider retry, plugin runtime refresh) are a different handoff and are not changed here; #178102 addresses that case through the recorder's persisted prompt. The two changes compose:
promptSuppressedis false whenever a recorder exists.Not changed on purpose: the stranded-reply retry itself, the host's finalization request rules, the two-attempt finalization limit, and the
message_tool_onlyprivacy of the original final.Evidence
Maintainer review
The contributor implementation was retained after source review and simplification. Current main still requires a current-turn prompt identity even when stranded-reply recovery deliberately suppresses that prompt and removes its recorder (
settled-turn-evidence.ts:52). The patch uses the existing evidence owner and keeps exact mirrored payload, ordering, uniqueness, and settled-tool-boundary checks; ordinary recorder-backed turns retain their prompt requirement. The separatefield_limitincident remains tracked in #164191.The existing focused regression would fail on the base because the promptless attempt returns unavailable context instead of the captured prior conversation and completed tool evidence. Contributor-reported base/head and live evidence below is preserved; it was not rerun during maintainer takeover. Local contributor-code execution, live Gateway/channel e2e, broad suites, and full typechecks were skipped per maintainer policy. PR CI owns executable regression and broad proof.
Main was integrated because Codex inference context, native turn handling, sandbox checks, and package metadata had materially changed since the original PR base. Contributor commits and credit are preserved.
Static maintainer checks: oxlint inspected all seven changed TypeScript files (231 rules, zero diagnostics); oxfmt passed all nine changed files;
git diff --checkpassed. Independent Codex autoreview on contributor head7e00f60762e48f808ee930f8feeb1dddc89bab52returned scoped-clean, no actionable P0–P2 findings. Production +16/−2, tests +175/−13, docs +6/−1; the small production increase carries the explicit promptless-turn contract through existing owners. No unrelated cleanup was added to force a negative line count.Integration head:
c249b6b1f6985f7d419059e8ce3a280b4706b662, merging main377c0fcb1f106b6ebda3f069d554d1d64732998b. The nine changed files are byte-identical to the reviewed contributor head. Static lint, formatting, and diff checks also pass after integration. Exact-head CI run 40059895146 completed with 36 successful jobs, 29 skipped jobs, and two failed jobs: one inherited test failure and its aggregate CI gate. The changed core/Codex test lanes, lint, types, docs, and boundary checks passed. All six previously cancelled Security High checks passed in CodeQL run 40059895100.The inherited failure is PR job
checks-node-compact-small-4:test/vitest-projects-config.test.ts:288reports thatscripts/control-ui-retention/dependency-retention.test.tsis missing from full-suite ownership. Scheduled main run 40058965760, jobchecks-node-compact-small-39, at232ca2aaf055addb16c8d1231c922e40a8b8347e, has the identical assertion and missing path. Those inputs are unchanged between that main commit and integrated main; this PR changes neither. The overall CI result remains red and is not represented as passing. No CI rerun or unrelated source change was made.Contributor evidence
extensions/codex/src/app-server/settled-turn-context.test.ts: a turn with no prompt row and prior context (turn-1:prompt, assistant text) is rejected without the flag and captured with it, with the prior turn projected ahead of the tool call and result; a suppressed-prompt turn that carries a prompt row is rejected withprovenance_rejected. Both red on the base (2 failed, 21 passed), green with the fix (23 passed).extensions/codex/src/app-server/run-attempt.settled-finalization.test-support.ts(registered inrun-attempt.test.ts): the real attempt path with a stranded-retry-shaped request (suppressed persistence, no recorder) on a session whose transcript already holds the user turn and the private final. On the base it logscapture failed {reason: "provenance_rejected"}andcontext is unavailable; with the fix it capturessource: "harness"evidence holding the prior user turn, the prior assistant text, the tool call and its output. Red on the base (1 failed), green with the fix.extensions/codex/src/app-server/settled-turn-finalizer.native.test.ts, new scenario "prompt-less stranded-reply retry": the real Codex app server (the pinned native binary) runs one shell command for a turn with suppressed prompt persistence and no recorder, the turn ends with no assistant text, and the realrunCodexSettledTurnFinalizationthen persists exactly one answer in an isolated, tool-free side thread without repeating the command (the action marker file holds one line). On the base the turn loses its settled evidence (Native turn lost its settled-tool evidence); with the fix it passes. A live-provider variant (OPENCLAW_LIVE_TEST=1 OPENCLAW_LIVE_CODEX_SETTLED_FINALIZATION=1) runs the same path against a real OpenAI model: the model runs the command, the turn ends without text, and the finalizer's answer contains the command output. Live result: red on the base, green with the fix; the existing hidden-notification live case passes on both.src/agents/embedded-agent-runner/run/settled-turn-finalization.test.ts(host side, unchanged code, contract guard for the tail this fix unblocks): inmessage_tool_onlymode with a harness-captured context, a real finalizer answer is marked to cross source-reply suppression and reaches the payloads, while an empty finalization leaves no visible text and no deliverable payload for the retry's diagnostic to misread. Green on base and head (37 passed).settled-turn-finalizer.test.ts,settled-turn-finalizer.native.test.ts,settled-turn-prior-context.test.ts,settled-turn-projection.test.ts,session-history.test.ts,session-history-control.test.ts,session-history-worker-runtime.test.ts,run-attempt.retry-continuation.test.ts(115 tests).extensions/codex/README.mdanddocs/plugins/sdk-agent-harness/sessions-and-results.mddescribe the prompt-less evidence anchor.pnpm tsgo:core,pnpm lint,pnpm format:check,git diff --check: see the CI lanes on this head.Live run: Gateway over Telegram, fix vs. fix reverted (staged model replies)
An isolated Gateway from this branch (and from the base, with the three source files reverted), the Codex plugin on the pinned Codex app server,
openai/gpt-5.6-terra, a real Telegram bot in a direct chat, and a human sending the messages. Live models would not produce the reported model behavior on cue (11 of 11 unstaged retries delivered through the message tool), so a local HTTPS proxy in front of the OpenAI API scripted exactly two model replies per message: the first answer as plain text without the message tool (the private final), and the stranded-reply retry as oneexectool call followed by no text and no send. Every other model call, including the settled-turn finalizer's answer, went to the real OpenAI API unchanged. Logs redacted.Base, message "What is 7 times 8?":
This branch, messages "What is 9 times 6?" and "What is 7 times 8?" (two runs, same result):
The retry's tool ran once and the finalizer answer was produced by the real model from the settled evidence and delivered to the chat as the only reply.
Captured runtime trace (native app server, live OpenAI model)
The new native scenario, run once more with temporary trace lines (not committed) printing the capture warnings, the settled context, the finalizer's app-server calls and the action marker file. Paths redacted.
Base (fix reverted), same scenario, scripted and live provider:
This branch, live provider:
The scripted run on this branch shows the same shape: no prompt row, capture with no warnings, settled context
user, assistant, function_call, function_call_output, one tool-free finalizer turn, answer persisted, marker file holds one line.Live run (real Gateway, real Codex app server, real OpenAI model, Telegram DM)
An isolated Gateway from this branch with the Codex plugin,
openai/gpt-5.6-terra(the reporter's model) onagentRuntime: codex, a Telegram bot in a direct chat, and a human sending messages. 15 turns in four rounds (plain; with a workspaceAGENTS.mdrule "never call the message tool"; with a rule "send only through the shell tool"; with a rule to always pass an explicit channel and target). The first half of the report reproduced 11 times: the model answered as plain text withoutmessage(action=send), the Gateway logged[source-reply/private-final] ... (message_tool_only) ..., and the stranded-reply retry ran as a Codex turn. In every one of those 11 retries the model obeyed the retry's system note, calledmessage(action=send), and the reply was delivered. The retry never ended in tool work without a delivery, so the settled-turn capture on the retry (the path this change fixes) did not run in these unstaged rounds; the staged Gateway run above covers it; that path is proven by the attempt-level test above, which drives the production capture code with the retry's exact parameter shape, and by the native app-server scenario above, which also runs the real finalizer. Same observation withgpt-5.6-solover three turns.