Repository navigation
fix(codex): skip settled-turn finalization capture after sessions_yield - #124176
masatohoshino wants to merge 1 commit into
Conversation
|
🦞👀 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. Reviewed September 21, 2026, 1:32 AM ET / 05:32 UTC (Revision 7). ClawSweeper reviewWhat this changesThe Codex plugin skips unnecessary finalization-context capture after intentional session yields and adds regression coverage for successful and failed terminal outcomes. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix absent from current main and the latest release. The updated evidence resolves the previous review’s test-cost request, and no blocking correctness or security finding remains. Priority: P2 Review scores
Verification
How this fits togetherThe Codex plugin receives model and tool events from Codex app-server and turns them into OpenClaw attempt results. Its finalizer captures context for unfinished silent tool turns so the agent runner can produce a final answer; intentional yields already bypass that recovery. flowchart TD
A[Codex model turn] --> B[Dynamic tool bridge]
B --> C[Recorded yield state]
A --> D[Turn completion]
C --> E[Finalization capture decision]
D --> E
E -->|Intentional yield| F[Return paused attempt]
E -->|Eligible silent tool turn| G[Capture recovery context]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +5, Tests +68. Total +73 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep intentional yields outside finalization-context capture while retaining ordinary silent-tool recovery and its legitimate diagnostics. Do we have a high-confidence way to reproduce the issue? Yes: current-main source admits silent yielded tool turns into context capture, and the supplied before/after traces exercise that path with unreplayable image history. This review inspected source and recorded evidence without executing the reproduction. Is this the best way to solve the issue? Yes: excluding the existing yield signal at the capture owner matches downstream recovery gates and avoids adding another policy or configuration surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 00caa84ce72c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
The PR body's "Real behavior proof" section now includes a source citation |
|
Related merge: #140367 landed in main on September 6, 2026 (04081aa). It changes incomplete-completions classification and the embedded runner's commentary-aware recovery gates. It does not modify the Codex app-server context-capture predicate in |
shouldCaptureSettledTurnFinalizationContext treated a successful sessions_yield turn (no assistant text, a toolResult, no prompt error) the same as a genuinely incomplete turn, triggering a doomed context-capture attempt and a false "codex settled-turn finalization context is unavailable" warning. Add !toolState.yieldDetected to the predicate, mirroring the existing yieldDetected gate in incomplete-turn-recovery.ts. Fixes openclaw#122076
597659f to
335116f
Compare
|
🦞👀 Re-review progress:
|
Closes #122076
What Problem This Solves
Fixes: a Codex app-server turn that intentionally ends with a successful
sessions_yieldis treated as an unfinished silent tool turn, so OpenClawattempts settled-turn finalization context capture for it and logs
codex settled-turn finalization context is unavailablewhenever that capturecannot replay the branch — for a turn that completed exactly as intended.
User Impact
Operators no longer see a false "settled-turn finalization context is
unavailable" warning after a Codex turn pauses through
sessions_yield, so ahealthy intentional pause stops looking like a finalization failure. Ordinary
non-yield silent tool-result turns are unchanged: they still capture
settled-turn finalization context, and they still emit that warning when the
capture genuinely fails.
Why This Change Was Made
shouldCaptureSettledTurnFinalizationContextinextensions/codex/src/app-server/run-attempt-finalize.tsselects the capturefrom "no assistant text, a tool result, and no prompt error (or failure
finalization explicitly allowed)". A successful
sessions_yieldturn hasexactly that shape, so the finalizer could not tell an intentional pause from an
incomplete turn. This adds a
!toolState.yieldDetectedconjunct — the same"a detected yield is already handled" policy the sibling incomplete-turn gates
already apply (
shouldSkipNonVisibleTurnRetryandresolveSettledToolTerminalContinuationInstructioninsrc/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts,resolveSilentToolResultReplyPayloadinincomplete-turn-resolution.ts).The exclusion covers both terminal outcomes deliberately, because every consumer
of
settledTurnFinalizationContextalready returns early on a detected yield:resolveSettledToolTerminalContinuationInstructionreturnsnullfor a yield,and it is the only path that reaches
runCodexSettledTurnFinalization— thesole reader of the context object;
countSettledTurnDeliveryPayloadsfeeds only that resolver,shouldTreatEmptyAssistantReplyAsSilentandresolveSilentToolResultReplyPayload, all of which short-circuit on a yield.A yielded turn therefore consumes no captured context whether it succeeds or
fails; capturing it only risks the false warning. Both outcomes are covered by
the regression cases below.
Evidence
Base:
befbed6bd6e(upstream/main). Head:335116fe6dd.Diff: one production line plus its comment in
run-attempt-finalize.ts; twoparametrized regression cases in the file that now owns settled-finalization
coverage (
run-attempt.settled-finalization.test-support.ts); one optionalsessionKeyargument on the sharedattachSqliteSessionTargettest helper,whose default is unchanged for every existing caller.
Full-path real behavior proof
Each row below is one complete run of the production attempt path
(
runCodexAppServerAttempt→finalizeCodexAttempt) against a realcodex app-serverchild process and a real model turn, with the realsessions_yieldtool (src/agents/tools/sessions-yield-tool.ts) reached throughthe production dynamic-tool bridge and the real attempt-local
toolState.yieldDetectedwiring. Nothing about the tool call, the process, themodel turn or the finalizer is mocked. "before" runs the identical harness
against the branch's exact base commit
befbed6bd6e.The two
unreplayable historyrows are the reported failure mode: the sessioncarries an ordinary earlier user image turn, which the settled-turn projection
cannot replay, so capture fails closed and the warning is emitted.
befbed6bd6e)335116fe6dd)source: harness)undefinedsource: unavailable+ false warning emittedundefined, no warningsource: harness)source: harness)source: unavailable+ warning emittedsource: unavailable+ warning emittedAll eight runs (four cases, each run before and after) reached
terminal.kind: "ok", and in every run the turn had the exact shape thepredicate reads:
assistantTextsall blank and atoolResultpresent inmessagesSnapshot. The only input that differed between the yielded rows andthe control rows was
yieldDetected.Recorded observations (redacted to methods, types and tool names)
Yielded case, app-server transcript — identical before and after:
Yielded turn with unreplayable history, before (
befbed6bd6e):Same case, after (
335116fe6dd):Non-yield control with the same unreplayable history, after (
335116fe6dd)— the legitimate warning is preserved:
Command (the driver is a local-only
*.real-binary.live.test.tsharness, notcommitted to this branch; it only builds attempt params, starts the real
app-server client and records the finalizer's own outputs and warn calls):
Focused tests
pnpm test extensions/codex/src/app-server/run-attempt.test.ts— 194 passed,including the pre-existing non-yield settled-finalization
it.eachmatrix.Test cost, as the repository policy requires:
pnpm test extensions/codex/src/app-server/run-attempt.test.ts --maxWorkers=1— 194 passed, 92.8 s wall (Vitest-reported duration 91.08 s).
completed-yield case and 867 ms for the allowed-failure case. They use the
suite's existing fake-transport fixture, add no timers, sleeps, polling,
process boots, serial config or worker pin.
All 12
checks-node-changed-extensions-*shards succeeded, between 3 m 48 sand 7 m 42 s wall each; the check-run API does not attribute an individual
file to a shard, so a per-file CI figure is not available.
The two new cases drive
runCodexAppServerAttemptwith the fake app-servertransport used by every other test in that file, but with the real
sessions_yieldtool, the real dynamic-tool bridge and realtoolStatewiring,and assert that
settledTurnFinalizationContextisundefinedand that no"codex settled-turn finalization context is unavailable"warning was logged —for a completed yield and for a yield followed by an allowed-failure terminal
outcome. Both fail on the unpatched predicate with
expected CodexSettledTurnContext{…} to be undefined.Other checks
oxfmt --checkandoxlinton the three changed files: clean.pnpm tsgo:extensionsandpnpm tsgo:extensions:test: clean.git diff --check: clean.pnpm check:changed: "mobile protocol event coverage" and "conflict markers"pass. The "line-cap growth ratchet" lane could not run locally — it shells out
to
git cat-file --batch -z, unsupported by the Git 2.34.1 installed here, andit fails identically on an unmodified checkout of
befbed6bd6e. CI covers it:checks-fast-baseline-ratchetssucceeded on this head.What was not tested
createSessionsYieldTool's own requester/session-store side effects beyond theyield claim (
onBeforeYield) are not exercised; they need a real spawnedsubagent and are unrelated to this predicate.