Skip to content

fix(codex): recover final answers after checkpointed work and terminal reasoning - #185310

Merged
obviyus merged 3 commits into
openclaw:mainfrom
ericcaiwx-star:codex/185286-terminal-reasoning-order
Oct 27, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
ericcaiwx-star:codex/185286-terminal-reasoning-order

Conversation

@ericcaiwx-star

@ericcaiwx-star ericcaiwx-star commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #185286

What Problem This Solves

Fixes Codex losing its final answer after completed checkpointed work is followed by terminal aggregate reasoning and an empty final response.

User Impact

The existing passive finalizer can recover the completed result without repeating actions. Strict transcript identity, payload and ordering checks remain intact.

Why This Change Was Made

Move the existing aggregate reasoning block after checkpointed visible work and before the final assistant, matching canonical history. No new prompt, verifier exception, recovery policy, storage field or permission change.

Thanks to @ericcaiwx-star for the fix and regression coverage.

Evidence

Built native Gateway capture.

Built Linux Gateway and actual pinned Codex app-server 0.164.0, with a local Responses fixture and model confirmed in both real catalogs. Shipped sessions.create plus agent CLI executes a real native command once, then receives terminal aggregate reasoning without a final answer.

Main fails recovery twice with provenance rejection and no finalizer request. This head recovers twice: two source requests, one passive finalizer request containing completed command evidence, CLI exit 0, and the recovered answer in two independent chat.history reads. Every command writes completed-once exactly once; zero tool failures. The finalizer performs no tool calls. A normal-order control recovers on both refs without repeating the command.

Both runtime builds, all 10 native finalizer tests and changed-file formatting/lint passed. Simplification retains the existing blocks and owners: production +8/-8, tests/support +22/-2. No hosted provider acceptance claim.

Merge danger

Two-way door: revert fully restores old snapshot ordering; no migration or persisted-data rewrite. Blast radius is terminal Codex snapshot ordering after checkpointed work, not model routing, prompts, action authorization or verifier strictness.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Moves aggregate reasoning after completed visible work so final-answer recovery sees the same order as durable history.

Example: A native command writes completed-once, followed by aggregate reasoning and an empty final response.

  • Before: Recovery rejects the transcript order, the CLI exits 1, and no answer appears in history.
  • After: Recovery produces a durable answer, the CLI exits 0, and the command still executes exactly once.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused producer repair with shipped-entry-point proof, meaningful native regression coverage, unchanged persistence formats, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The exact-head built Linux Gateway and native Codex 0.164.0 exercise sessions.create, the agent CLI, a real command, terminal reasoning, passive recovery, and durable history against a local Responses endpoint; paired base failures, candidate successes, and a normal-order control isolate the changed behavior without claiming hosted-provider acceptance.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users receive no substantive final answer even though Codex completed the requested tool work.
Reason: The correction restores existing recovery behavior while retaining transcript ownership, reasoning visibility, and passive-finalizer restrictions.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR narrowly fixes a current Codex recovery defect, with convincing Gateway proof and no actionable findings; exact-head CI remains pending.

Priority: P1
Reviewed head: 0d504b3aa07567055cb1e3467e02a6e6e347a767

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The shipped Gateway scenario is covered; a base-red run of the committed native regression is not explicitly recorded.
Agent review details

How this fits together

The Codex plugin projects native turn events into OpenClaw transcript messages; settled-turn recovery verifies those messages against durable history before requesting a passive final answer.

flowchart TD
  A[Native Codex events] --> B[Event projector]
  B --> C[Completed work checkpoints]
  B --> D[Terminal snapshot]
  C --> E[Durable transcript]
  D --> F[Strict evidence verifier]
  E --> F
  F --> G[Passive finalizer]
  G --> H[Answer and history]
Loading

Technical review

Best possible solution:

Land the producer-order correction with its native regression once the existing CI gates pass.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the ordering mismatch, and supplied base/head Gateway output demonstrates its failure and recovery; this read-only review executed no target code.

Is this the best way to solve the issue?

Correcting the snapshot producer is the smallest complete fix: it matches authoritative checkpoint order without relaxing verification or repeating completed actions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 921f25822b76.

Provenance checked

  • Aggregate reasoning placement changes intended behavior with a stated reason (fd081d6: Preserve commentary durably and order it with tool activity; the original snapshot also placed reasoning before visible work.)
  • Typed reasoning representation keeps the original intent (9846f18: Keep saved reasoning distinct from answer text and governed by existing visibility controls.)
  • Native finalizer test fixture keeps the original intent (test(agents,chat,ci): remove low-value tests (batch d309) #178243: Consolidate repeated test setup while retaining distinct recovery contracts; this PR extends the existing scenario table.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit fd081d6 adds extensions/codex/src/app-server/event-projector-snapshot.ts:39 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fd081d652116; files: extensions/codex/src/app-server/event-projector-snapshot.ts)
  • Hosung Park: Raw commit c12e36d adds extensions/codex/src/app-server/settled-turn-finalizer.native.test.ts:539 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c12e36d64d31; files: extensions/codex/src/app-server/settled-turn-finalizer.native.test.ts)

PR surface

Source 0, Tests +20. Total +20 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 8 8 0
Tests 2 22 2 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 30 10 +20

Review metrics

Metric Value Why it matters
Production versus test changes Production +8/-8; tests/support +22/-2 Production only relocates existing code; test growth adds one distinct terminal-reasoning recovery scenario within the existing fixture.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #185286
Summary: This PR directly repairs the snapshot-order defect reported in the canonical issue; the merged recovery-wording change is adjacent work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The linked production report and supplied Gateway reproduction show a missing substantive answer after successful tool work.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-27T02:19:23.792Z sha 584eead :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-27T02:33:12.055Z sha 584eead :: needs maintainer review before merge. :: none

Reviewed October 27, 2026, 12:06 AM ET / 04:06 UTC (Revision 3).

@ericcaiwx-star

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Head 584eead935b3cd71cc5d54dac16e678ff1ed034e now has executed named-base failure and exact-head native/built CLI/Gateway proof in the PR body. The completed native action runs once; isolated tool-free recovery produces a visible and durable answer; shutdown closes the database and Gateway cleanly. The 76 related tests pass, canonical independent P0–P2 AutoReview is clean, and current-head CI has no failures or pending checks. The body also records the untouched dead-export diagnostics and the synthetic-provider coverage boundary. Please assess current-head proof sufficiency and remaining author work.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 27, 2026
@ericcaiwx-star
ericcaiwx-star marked this pull request as ready for review October 27, 2026 02:37
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Built Linux Gateway + pinned native Codex app-server 0.164.0 on Node 24.22.1. Frozen main b3fa02e; candidate 0d504b3. Native model/list and the refreshed Gateway models.list both confirm openai/gpt-5.6-sol. No model catalog or database was seeded.

Shipped sessions.create selects Codex, then openclaw agent --session-key <key> --model openai/gpt-5.6-sol --message <synthetic-request> --json runs through the Gateway. A local Responses HTTP/SSE fixture uses the actual advertised native functions.exec/exec_command protocol: first response executes a real shell command appending completed-once to a task file; after its result, the second emits aggregate reasoning and no final answer.

Scenario                        main twice              candidate twice
Source Responses requests       2 / 2                   2 / 2
Native command writes           exactly 1 / 1           exactly 1 / 1
Native command failures         0 / 0                   0 / 0
Finalizer Requests              0 / 0                   1 / 1
Agent CLI exit                  1 / 1                   0 / 0
Recovered answer in CLI         no / no                 yes / yes
Answer in two chat.history reads no / no                yes / yes

Main logs finalization context capture failed reason=provenance_rejected, followed by Codex settled-turn finalization context is unavailable; the result is an incomplete turn, despite the successful command. The candidate's existing strict finalizer receives the completed command result and returns the recovered answer without repeating the action. Finalizer responses contain only assistant text, no tool calls; the native generic namespace envelope remains present, so this is a no-tool-execution/passive-finalizer claim, not a claim that its wire request contains literally zero tool descriptors.

Normal-order control (same real command and empty terminal response, without aggregate reasoning) recovers on both refs: 2 source requests, 1 finalizer request, one command write, CLI exit 0 and matching answer in both history reads.

Both normal runtime builds passed; all 10 focused native finalizer tests and changed-file formatting/lint passed. Strict identity/order/payload checks, prompts, runtime permissions and persistence formats are unchanged. Production +8/-8; tests/support +22/-2.

Setup failures were not accepted as proof: corrected a harness object delimiter, then adapted detection to the current native additional_tools envelope. The final matrix uses native text(result), with successful completed tool output and zero tool failures. Local scripted provider acceptance is proven; hosted OpenAI acceptance is not claimed.

@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper clawsweeper Bot removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@obviyus
obviyus merged commit 40b1f01 into openclaw:main Oct 27, 2026
126 of 130 checks passed
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Landed in 40b1f01. Thanks @ericcaiwx-star. Codex final-answer recovery now works when reasoning comes after completed work.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…l reasoning (openclaw#185310)

fix(codex): order checkpointed work before terminal reasoning so final-answer recovery succeeds

When terminal reasoning came after already-completed work, the Codex final-answer recovery snapshot put the reasoning first, so recovery rejected the turn (provenance_rejected) and the agent exited without an answer. The snapshot now keeps the checkpointed work first; verification is unchanged and no prompt text changes.

Evidence: built Linux Gateway with the real Codex app-server 0.164.0 and a local Responses fixture. On main the turn ran its command once, made no finalizer request, exited 1 and had no recovered answer in the CLI or history (twice); with this change it ran the command once, made one finalizer request, exited 0 and the answer appeared in the CLI and both history reads (twice). The normal order works on both refs. Details: openclaw#185310 (comment). Production +8/-8.

Thanks @ericcaiwx-star.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex terminal reasoning reorders checkpointed work and blocks final-answer recovery

2 participants