Skip to content

fix(codex): preserve steered turns after final replies - #180935

Closed
LeoStehlik wants to merge 5 commits into
openclaw:mainfrom
LeoStehlik:fix/codex-steering-terminal-release
Closed

LeoStehlik wants to merge 5 commits into
openclaw:mainfrom
LeoStehlik:fix/codex-steering-terminal-release

Conversation

@LeoStehlik

@LeoStehlik LeoStehlik commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a follow-up steered into native Codex while an earlier final reply is delivered can be interrupted before it receives an answer. The earlier reply's delivery state can also suppress that answer, and discarding the earlier terminal candidate can lose a successful sibling sessions_yield.

Related: #147759. This does not claim to fix #176028 or stale native-thread ownership.

User Impact

Steered follow-ups remain eligible for an answer after an earlier final reply, while a successful independent yield still ends the turn. No configuration, schema, migration, dependency, or public SDK changes are required.

Why This Change Was Made

The lifecycle controller remembers that steering was submitted even after its consumption receipt arrives. It removes the earlier final reply's terminal authority while preserving an independent terminal sibling. Confirmed consumption resets current-input reply suppression; previously suppressed item identities remain suppressed in terminal snapshots. Finalization reports the latest input's delivery state independently of historical send receipts and runtime refresh.

Once any steering is submitted, even a later final send answering that steer finishes through the existing native loop instead of the host's early-terminal optimization. Consumption confirms history admission, not completion of an answer. Explicit yield retains its existing authority. Ordinary non-steered final replies keep their existing behavior.

This incorporates main's bounded steering drain from #184062; that change handles acknowledgement-to-consumption timing but does not address the later answer, projection, and finalization gaps above. The current contributor head also preserves upstream raw-item role checks and terminal admission/drain handling.

Evidence

Independent autoreview of this integrated head remains pending. Earlier helper attempts did not produce a complete verdict and are not counted as a passing review.

  • Regression proof: both consumption/release orderings fail on base 837a38a625cc915ab17c9d204c8106235c5dafd1 by losing the steered partial reply; the repaired candidate passed 130 tests across seven suites, followed by 38 affected tests after the final helper extraction. Inventory checks passed 32 tests. These local runs precede the contributor's latest integration.
  • Current contributor head f1b1a0eca5896871578efab899e004d4d08ae886: the contributor reports 122/122 tests across seven lifecycle, steering, assistant projection, and finalization suites, with targeted typed lint, formatting, and normal commit hooks passing. Exact-head hosted CI passed, including the new test's full-suite registration, openclaw/ci-gate, and security checks: https://github.com/openclaw/openclaw/actions/runs/40311973916 and https://github.com/openclaw/openclaw/actions/runs/40313846648.
  • Production +93/-24 (net +69); tests and inventory +447/-202 (net +245). Existing test scaffolding was extracted and reused; the remaining production growth keeps submitted steering, suppressed item identity, independent yield, and current-input delivery facts with their existing owners.
  • Historical contributor live proof used an isolated Gateway, native Codex 0.160.0, a real model, and a synthetic QA HTTP channel. With A's delivery receipt held, native steering accepted B; releasing A produced actual outbound PROOF_ANSWER_A and PROOF_ANSWER_B. The earlier repair delivered only A; the fixed run passed in 20.262 seconds of test execution (58.81 seconds command time).
  • No fresh real-model/Gateway run was made for the latest integration. The prior live proof remains evidence for its original head; direct/nested successful-yield sibling orderings have regression coverage, not live-model proof. No live installation was changed.

Credit: original fix, regression coverage, and Gateway investigation by @LeoStehlik.

Co-authored-by: Leo Stehlik [email protected]

@clawsweeper

clawsweeper Bot commented Oct 22, 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-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@LeoStehlik
LeoStehlik marked this pull request as ready for review October 22, 2026 19:45
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Preserves submitted Codex follow-ups, restores their answer visibility, and retains independent terminal yields after an earlier final reply.

Example: A delivers PROOF_ANSWER_A while B is submitted through the Gateway.

  • Before: The earlier final reply can interrupt B or suppress PROOF_ANSWER_B.
  • After: The supplied Gateway trace records PROOF_ANSWER_A followed by PROOF_ANSWER_B.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful delivery repair with production-entry evidence and no actionable finding; readiness remains capped by the unresolved completion-policy decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied isolated Gateway/native Codex/real-model trace exercises held A delivery, accepted B steering, and actual outbound A then B on repair head 8f47d92; merged-head evidence records 122 focused passing tests, while live successful-yield coverage remains explicitly limited.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: A follow-up sent while Codex finishes an earlier reply can be accepted yet receive no visible answer.
Reason: The delivery repair has concrete value, but the intentional change to final-send completion behavior remains an unresolved owner choice.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a remaining Codex follow-up delivery defect that the merged consumption-drain repair does not solve; no actionable introduced defect was found, but the completion-policy tradeoff needs an owner decision.

Priority: P1
Reviewed head: f1b1a0eca5896871578efab899e004d4d08ae886
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should final source sends use native completion for the remainder of a native turn once any steering has been submitted, including a later send answering that steer?
  • Recommendation: Accept native completion after steering: Accept the documented turn-wide tradeoff to preserve follow-up answers while retaining explicit terminal yields.
  • Why: This deliberately relaxes the early-completion policy established by feat(agents): end runs after confirmed final source replies #170653 and can permit another native model continuation after delivery; no owner acceptance is recorded.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Tests

  • Missing end-to-end proof: Successful final-send-plus-yield has direct and nested regression coverage but no successful live control; the recorded Gateway delivery run predates the upstream integration.
Agent review details

How this fits together

The Codex plugin translates active-run follow-ups into native steering and converts native notifications and tool-delivery receipts into visible answers and terminal run outcomes.

flowchart TD
  A[Gateway follow-up] --> B[Steering queue]
  B --> C[Native Codex turn]
  C --> D[Consumption notification]
  D --> E[Assistant projection]
  F[Tool delivery receipts] --> G[Lifecycle and finalizer]
  E --> G
  G --> H[Visible answer and run outcome]
Loading

Technical review

Best possible solution:

Preserve follow-up delivery through the existing queue, projector, and finalizer owners with an explicit decision on native completion after steered final sends.

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

Current-main source shows terminal release can finish after consumption without answering the steer, while its unchanged final-reply flag suppresses later assistant output; the discussion independently corroborates both receipt orderings.

Is this the best way to solve the issue?

The patch repairs the existing owners without adding configuration, persistence, or a competing execution path, but its broader final-send completion policy requires owner acceptance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6af393748075.

Provenance checked

  • Final-source-reply termination and suppression changes intended behavior with a stated reason (7a5529f: End runs after confirmed current-source final actions to avoid extra model requests and redundant replies.)
  • Steering consumption identity keeps the original intent (7a3c26b: Distinguish RPC acceptance from matching transcript consumption and avoid falsely reporting delivery before interruption.)
  • Terminal sibling admission keeps the original intent (9c9b2bb: Preserve finished tool-authored replies while requiring whole-batch sibling classification.)
  • Steered transcript ordering keeps the original intent (c108ae6: Keep completed assistant output before consumed steering and preserve stable item identity through transcript refresh.)
  • Refresh-specific steering snapshots keeps the original intent (cf9cbef: Carry accepted prepared inputs across managed runtime refresh without replaying completed effects.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Alexis Gallagher: Raw commit 7a3c26b adds extensions/codex/src/app-server/attempt-steering.ts:182 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7a3c26b509f1; files: extensions/codex/src/app-server/attempt-steering.ts)
  • Paul Bohm: Raw commit f83b7ad adds extensions/codex/src/app-server/attempt-steering.ts:500 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f83b7ade15f3; files: extensions/codex/src/app-server/attempt-steering.ts)

PR surface

Source +69, Tests +245. Total +314 across 11 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 6 93 24 +69
Tests 5 447 202 +245
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 540 226 +314

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Accepted follow-ups can lose their answer in an active Codex conversation, with source-level corroboration and supplied real-Gateway delivery evidence.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • 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 (3 earlier review cycles)
  • reviewed 2026-10-22T20:04:13.029Z sha 1138b44 :: needs real behavior proof before merge. :: [P1] Scope final-reply suppression to the input it answered | [P2] Preserve explicit yield beside a delivered final reply
  • reviewed 2026-10-22T21:59:00.652Z sha 8f47d92 :: blocked before merge. :: [P2] Register the new steering suite with its full-suite owner
  • reviewed 2026-10-22T22:12:26.389Z sha ddf42e3 :: blocked before merge. :: none

Reviewed October 26, 2026, 7:10 AM ET / 11:10 UTC (Revision 4).

@openclaw-barnacle openclaw-barnacle Bot added size: L triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: S labels Oct 22, 2026
@LeoStehlik

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Repair head: 8f47d92. Both reported mechanisms have red/green regressions; the body now includes actual isolated Gateway/native Codex/real-model QA HTTP evidence delivering A then B, plus the normal-finalizer propagation repair exposed by that test.

Explicit remaining proof limit: both receipt/release-check orderings and direct/nested final-send-plus-yield orders have deterministic regression coverage. Two extra live yield-control attempts omitted the requested yield call, so we do not claim live successful-yield proof. Please assess the updated repair and evidence with that limit.

@clawsweeper

clawsweeper Bot commented Oct 22, 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 22, 2026
@LeoStehlik

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed revision 2 test-suite ownership finding in ddf42e3: one inventory entry beside the existing lifecycle controller. Exact CI assertion reproduced red; all32 configuration tests and6 steering tests in the assigned worker lane pass locally. No production changes after the Gateway-proven8f47d927 repair. Required PR-body headings restored; context check passed before this push.

The upstream lifecycle-owner decision on native completion remains open and is explicitly recorded in the body. No owner acceptance or live successful-yield proof is claimed.

@clawsweeper

clawsweeper Bot commented Oct 22, 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. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@indra622

Copy link
Copy Markdown
Contributor

Independent source-level reproduction on main 7204b8c1c5f98ef24ffa7c25db0574e7084d4db6 confirms both receipt orderings. The existing 44 lifecycle tests pass. Two independently authored regression tests fail: a receipt before final-reply settlement still permits one mocked turn/interrupt request; a later receipt produces the accepted-unconfirmed warning. Each case submits steering once.

These cases overlap this PR, so no duplicate PR was prepared. The reproduction's formatting, targeted lint and targeted type checks pass. This exercises the production queue and lifecycle with an in-memory transport, not Gateway E2E. The PR was inspected read-only; the author's live proof was not independently rerun. In particular, I have not independently verified this PR's fix or the live final-send-plus-yield combination. The reproduction and review were prepared with AI assistance.

@LeoStehlik

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Conflicts resolved at f1b1a0e. Updated PR evidence records 122 passing focused tests, static gates, independent source review, and the limits of prior-head live proof.

@clawsweeper

clawsweeper Bot commented Oct 26, 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 26, 2026
Prevent an authored sibling from restoring a delivered reply's terminal authority after steering, while preserving independent explicit yields.

Keep the projector result identity carrying host-issued TTS delivery provenance through finalization.

Co-authored-by: Leo Stehlik <[email protected]>
steipete added a commit that referenced this pull request Oct 26, 2026
Preserve a follow-up steered into native Codex while an earlier final reply is delivered. A steering consumption receipt records the input, not completion of its answer, so the earlier reply must not interrupt the native turn or suppress the follow-up answer.

Retain submitted steering through terminal release, reset current-input suppression on confirmed consumption, preserve suppressed assistant item identities in terminal snapshots, and report current-input delivery independently of historical receipts. Independent successful yield retains its terminal authority, including nested Code Mode siblings. Non-steered final replies retain their existing behavior.

Mixed final-send/authored-reply batches cannot restore discarded terminal authority after steering, while independent explicit yields remain effective. Preserve the projector result object so host-issued TTS delivery provenance survives finalization.

Once steering is submitted, later final sends also finish through the existing native loop instead of the host's early-terminal optimization. No configuration, schema, dependency, or public SDK change is introduced.

Replaces #180935.

Related: #147759

Co-authored-by: Leo Stehlik <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Thank you @LeoStehlik for the fix, regression coverage, and Gateway investigation. Your work and authorship were carried forward into #184992, which is now merged. Closing this superseded PR.

@steipete steipete closed this Oct 26, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
Preserve a follow-up steered into native Codex while an earlier final reply is delivered. A steering consumption receipt records the input, not completion of its answer, so the earlier reply must not interrupt the native turn or suppress the follow-up answer.

Retain submitted steering through terminal release, reset current-input suppression on confirmed consumption, preserve suppressed assistant item identities in terminal snapshots, and report current-input delivery independently of historical receipts. Independent successful yield retains its terminal authority, including nested Code Mode siblings. Non-steered final replies retain their existing behavior.

Mixed final-send/authored-reply batches cannot restore discarded terminal authority after steering, while independent explicit yields remain effective. Preserve the projector result object so host-issued TTS delivery provenance survives finalization.

Once steering is submitted, later final sends also finish through the existing native loop instead of the host's early-terminal optimization. No configuration, schema, dependency, or public SDK change is introduced.

Replaces openclaw#180935.

Related: openclaw#147759

Co-authored-by: Leo Stehlik <[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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Steering skips the message-tool answer on message-tool-only turns, so the earlier message never gets its reply

3 participants