Skip to content

fix(codex): unblock parents after native follow-up completion - #177577

Merged
steipete merged 4 commits into
openclaw:mainfrom
linancn:codex/fix-native-submission-retention
Oct 25, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
linancn:codex/fix-native-submission-retention

Conversation

@linancn

@linancn linancn commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Related: #172837. Follow-up to #175246.

What Problem This Solves

A parent request is refused as claimed by active work after a native Codex follow-up finishes while its result still awaits acknowledgment.

User Impact

The parent can cold-resume to receive the completed result. Active child execution stays protected, and pending results and submission receipts remain available until acknowledgment.

Why This Change Was Made

After successful follow-up admission, the existing monitor owns execution protection. Release the redundant submission-owned execution hold at that handoff; retain completion custody and receipt settlement under their existing owners. No schema, configuration, or delivery-policy change is needed.

Thanks to @linancn (Nan LI) for the fix and original proof. This builds on #175246’s terminal-parent retention repair.

Evidence

  • On main 397807c7374c41ffe434215e1e091edba2997474, both acknowledgment-order regressions fail at releaseCodexBoundLiveThread with the terminal parent still claimed; the other 20 custody tests pass. With the fix, all 22 custody tests pass, including active-child protection, pending receipt preservation, and exactly-once consumption after acknowledgment. The 22 custody cases total 421ms of test execution; baseline wrapper time was 273.67s, dominated by preparation. The seven selected custody, retention, release-retry, delivery, submission-store, and runner suites pass: 90/90 tests across two shards, 901.05s wrapper time on this host. After integrating main c8dfebcfaee8e8c25e9fee79304b59dd00717d8d, the affected custody file passes again (22/22; 376.91s Vitest duration, dominated by worker preparation).
  • Targeted extension oxlint and oxfmt pass. Independent Codex autoreview is scoped-clean with no P0–P2 findings. The broader changed-file runner passed production typechecking, plugin contract tests (10/10), and static guards. It caught a missing timing boolean in the new test; that is corrected and extension-test typechecking passes. Its precommit environment-budget comparison also passes after integration (457/457). Dead-export scans report 72 production, 1,136 script, and 84 full-tree entries, all in files unchanged from integrated main and none in this PR; no separate full base scan was run.
  • Production delta: +2/-2 (net zero); test delta: +82/-27 (net +55). The regression uses the actual cold-resume guard in both predecessor-acknowledgment orders. Shared notification fixtures replace old notification literals; callback-level retention instrumentation was removed because the active-work guard covers the behavior directly.
  • The prior real Codex 0.162.1 replay below drives native spawn and send_input with a scripted provider and held delivery acknowledgment: base rejects terminal parent resume, fixed execution protects active work then allows actual thread/resume with a pending receipt; acknowledgment consumes once. Its binding backend is in-memory, so it does not prove disk durability.
  • The prior isolated authenticated Gateway smoke at 1cb15871a7f99b0f7af6346f2a04581344dd1928 returns LIVE_A_OK, LIVE_B_OK, and LIVE_NEXT_OK. No fresh authenticated Gateway/channel run was made here: the existing live lane requires provider credentials and does not inject the pending-acknowledgment interval; building a new harness exceeds the best-effort live budget.
  • Independent validation separates this submission pin from the interrupted-child pin fixed by merged fix(codex): unblock replies after interrupted native children #179099. Open consolidation fix(codex): preserve native catalog and completion continuity #174900 does not contain this submission-owner change.

This fixes the stated follow-up lockout. Broader delivery retry and abandonment policy in #172837 remains outside this Related-only PR.

Prior inspectable redacted execution capture: real Codex pending-ack replay and live Gateway

These are excerpts from captured execution output, not expected-value examples. Only relevant fields are shown. Synthetic UUIDs are consistently aliased as P (parent), C (child), A/B (child turns), and P_B (parent follow-up turn); local paths/endpoints are omitted. No production data or credentials were used in this replay.

Runtime: codex-cli 0.162.1, real stdio app-server and native spawn/send_input; synthetic Responses output and a deliberately held completion-delivery callback. The guard calls below are the production releaseCodexBoundLiveThread. This replay is distinct from the live-model Gateway smoke at the end. Receipt writes/consumption use the production binding mutation API with its existing in-memory test-store backend; this replay does not prove disk durability or restart recovery. Native app-server execution, completion notifications, unsubscribe/resume, and the separately captured native rollout files are real.

Baseline — b8f91cb249b8c702cfc02befd6d2fb11215928f3

{"at":1792432690644,"event":"receipt-record","receipt":{"parentTurnId":"P_B","callId":"SEND_B","childThreadId":"C","submissionId":"B","predecessorRunId":"codex-thread:C","predecessorNativeTurnId":"A"}}
{"at":1792432690681,"event":"active","claimed":false,"protected":true,"holds":{"client":2,"parent":2,"child":1},"guard":{"error":"Error: Codex thread P is claimed by active work; stop it first."},"receiptCount":1}
{"method":"turn/completed","params":{"threadId":"C","turn":{"id":"B","status":"completed","items":[{"type":"agentMessage","text":"B_RESULT"}]}}}
{"at":1792432690687,"event":"delivery-pending","params":{"childSessionId":"C","childSessionKey":"codex-thread:C:turn:B","result":"B_RESULT"}}
{"at":1792432690886,"event":"terminal-pending-ack","claimed":false,"protected":true,"holds":{"client":1,"parent":1,"child":1},"receiptCount":1,"guard":{"error":"Error: Codex thread P is claimed by active work; stop it first."}}
{"event":"result","pending":{"claimed":false,"protected":true,"holds":{"client":1,"parent":1,"child":1},"receiptCount":1,"guard":{"error":"Error: Codex thread P is claimed by active work; stop it first."}},"ack":{"receiptCount":0,"deliveryCount":1,"holds":{"client":0,"parent":0,"child":0}},"outcome":"RED"}

Captured receipt-consume calls after releasing the acknowledgement gate: 1.

Fixed source — later committed unchanged as 1cb15871a7f99b0f7af6346f2a04581344dd1928

Submission-owner SHA-256: 69fea86a827910ecb12536e52b77e73a79b69b8e5454130f558a6936738acd9d (matches the committed file).

{"at":1792433382642,"event":"receipt-record","receipt":{"parentTurnId":"P_B","callId":"SEND_B","childThreadId":"C","submissionId":"B","predecessorRunId":"codex-thread:C","predecessorNativeTurnId":"A"}}
{"at":1792433382672,"event":"active","claimed":false,"protected":true,"holds":{"client":1,"parent":1,"child":0},"guard":{"error":"Error: Codex thread P is claimed by active work; stop it first."},"receiptCount":1}
{"method":"turn/completed","params":{"threadId":"C","turn":{"id":"B","status":"completed","items":[{"type":"agentMessage","text":"B_RESULT"}]}}}
{"at":1792433382677,"event":"delivery-pending","params":{"childSessionId":"C","childSessionKey":"codex-thread:C:turn:B","result":"B_RESULT"}}
{"at":1792433382882,"event":"terminal-pending-ack","claimed":false,"protected":false,"holds":{"client":0,"parent":0,"child":0},"receiptCount":1,"guard":{"released":true}}
{"event":"result","pending":{"claimed":false,"protected":false,"holds":{"client":0,"parent":0,"child":0},"receiptCount":1,"guard":{"released":true},"coldResume":{"threadId":"P","status":{"type":"idle"}}},"ack":{"receiptCount":0,"deliveryCount":1,"holds":{"client":0,"parent":0,"child":0}},"outcome":"GREEN"}

Captured receipt-consume calls: 1. In the fixed run, the coldResume fields are the actual awaited thread/resume response, obtained before releasing the acknowledgement gate.

Isolated live Gateway — committed head 1cb15871a7f99b0f7af6346f2a04581344dd1928

Real authenticated V1-capable model, real Codex 0.162.1 and fresh isolated Gateway state. No delivery fault injection in this healthy-flow smoke. The following fields were read back from actual Gateway terminal receipts, native lifecycle notifications and the persisted native rollout:

{
  "sourceRevision": "1cb15871a7f99b0f7af6346f2a04581344dd1928",
  "submissionOwnerSha256": "69fea86a827910ecb12536e52b77e73a79b69b8e5454130f558a6936738acd9d",
  "nativeSpawn": {
    "parentThreadId": "P",
    "parentTurnId": "P_A",
    "receiverThreadIds": [
      "C"
    ],
    "status": "completed"
  },
  "nativeSendInput": {
    "parentThreadId": "P",
    "parentTurnId": "P_B",
    "callId": "SEND_B",
    "receiverThreadIds": [
      "C"
    ],
    "status": "completed"
  },
  "completedChildTurnIds": [
    "A",
    "B"
  ],
  "visibleReplies": [
    "LIVE_A_OK",
    "LIVE_B_OK",
    "LIVE_NEXT_OK"
  ],
  "acceptedSubmission": {
    "submissionId": "B",
    "payloadType": "custom_tool_call_output",
    "callId": "CODEMODE_CALL"
  },
  "runStatuses": [
    {
      "label": "native-spawn-A",
      "status": "ok"
    },
    {
      "label": "native-followup-B",
      "status": "ok"
    },
    {
      "label": "ordinary-next-request",
      "status": "ok"
    }
  ]
}

The original observer-only failure and its native-history readback correction are disclosed above; the accepted submission ID B matches the same child's completed B turn. The live workload was not rerun to obtain this readback.

Final validation: exact-head CI run 40145460523 passed for 707bd6daa2dc4341eaa00bf0658d291d61085edf, including both changed-extension bundles and the CI gate. ClawSweeper reviewed the same head with no findings.

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-19T18:22:29.969563Z 1cb1587 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@linancn

linancn commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

The PR body now includes explicit reproduction/environment details, the completed real V1 Gateway follow-up/next-request smoke, and passing required CI on 1cb15871a7f99b0f7af6346f2a04581344dd1928. The previous review workflow reported lease_superseded and published no completed review. No source change was needed after validation.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Release the redundant submission execution hold after the native follow-up is admitted to the existing monitor.

Example: Child turn B completes with result B_RESULT while its delivery acknowledgment remains pending.

  • Before: Parent P cannot cold-resume because the submission still protects it as active work.
  • After: Parent P can resume while the receipt remains pending; acknowledgment later consumes the receipt once.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The narrow patch is correct and supported by real execution evidence; it delivers only the follow-up lockout portion of the broader related issue.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The supplied real Codex 0.162.1 stdio replay exercises native spawn/send_input, production release protection, held acknowledgment, actual parent thread/resume before acknowledgment, and exactly-once receipt consumption; the separate authenticated Gateway smoke verifies ordinary follow-up continuity.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A completed native follow-up can leave the parent refusing the next request while its result awaits acknowledgment.
Reason: The focused fix restores the documented separation of execution protection and result custody; the broader related issue's retry and abandonment work remains outside this Related-only PR.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a remaining parent-resume lockout on current main with a minimal ownership handoff and no actionable correctness findings.

Priority: P1
Reviewed head: 707bd6daa2dc4341eaa00bf0658d291d61085edf

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Codex plugin observes native follow-up submissions and hands admitted child execution to its monitor; completion custody and binding receipts independently preserve pending results.

flowchart TD
  A[Native send_input] --> B[Submission owner]
  B --> C[Child monitor]
  C --> D[Active execution protection]
  C --> E[Completion delivery]
  B --> F[Pending receipt]
  E --> G[Delivery acknowledgment]
  G --> F
Loading

Technical review

Best possible solution:

Land the existing submission-to-monitor handoff after the required checks pass, preserving receipt settlement and completion custody.

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

The source establishes the retained submission pin, and supplied baseline/fixed native execution captures and independent regression results demonstrate the failure; this read-only review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete repair for the stated follow-up lockout: release the redundant hold after successful admission while retaining the existing monitor, completion, and receipt owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6113057491a2.

Provenance checked

  • Submission promotion and retention keeps the original intent (6652f7e: Remove the Tasks runtime while preserving native receipt ownership until acknowledgment.)
  • Custody regression fixtures keeps the original intent (test(cli, media, gateway): remove low-value tests (batch d215) #165651: Consolidate duplicate tests while retaining independent lifecycle and authority coverage; this PR extends the existing owner fixture with distinct acknowledgment-order regressions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source 0, Tests +55. Total +55 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 82 27 +55
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 84 29 +55

Review metrics

Metric Value Why it matters
Production versus test delta Production +2/-2; tests +82/-27 The test growth exercises two distinct acknowledgment orderings through the real release guard and reuses the existing custody fixture.

Root-cause cluster

Relationship: partial_overlap
Canonical: #172837
Summary: This PR addresses the submission-owned follow-up pin within the broader native completion report; terminal-child and interrupted-child monitor pins have separate merged repairs.

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: Completed native follow-ups can prevent subsequent parent requests and result delivery despite execution having ended.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; 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-19T18:51:18.100Z sha 1cb1587 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T19:07:29.273Z sha 1cb1587 :: needs maintainer review before merge. :: none

Reviewed October 24, 2026, 8:13 PM ET / October 25, 2026, 00:13 UTC (Revision 3).

@linancn

linancn commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the sole proof request in #177577 (comment). The PR body now embeds inspectable redacted execution captures: real Codex baseline/fixed pending-ack replay (active guard rejection, completed B notification, cold resume while receiptCount=1, and one receipt consumption), plus actual live Gateway native lifecycle and terminal-receipt readback. The captured fixed source SHA-256 matches the committed owner file. Fixture boundaries and the earlier observer-only miscount remain explicit. No source changes; exact-head CI remains green.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. labels Oct 19, 2026
@DonnieFi

Copy link
Copy Markdown
Contributor

Thanks @linancn — this is the right follow-up after #175246 for the submission-owned parent pin on #172837.

We're reviewing this branch as the next landable fix rather than replacing it. Credit stays with you for the retention release and the custody regression coverage.

@DonnieFi

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Maintainer landing path: please refresh exact-head review for 1cb15871a7f99b0f7af6346f2a04581344dd1928 so we can merge. Credit stays with @linancn.

@DonnieFi

Copy link
Copy Markdown
Contributor

Also quoting @Stronggenetics here: the contention/parent-retention contract this PR builds on came through #176177 (and was already adapted into #175246). Thanks for that groundwork.

@clawsweeper status

@DonnieFi

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@LeoStehlik

Copy link
Copy Markdown
Contributor

Independent validation in support of this fix. Without the patch, both follow-up acknowledgment orderings failed at parent cold resume with claimed by active work; stop it first. With this patch, both pass, while the running-child guard and pending receipt remain intact.

We applied the production deltas from #179099 (30e7861a765f8cbf71fe5b96723499c4c2971b1b) and #177577 (1cb15871a7f99b0f7af6346f2a04581344dd1928) to an isolated checkout of main at d575014d142a53a8dac4c542e888c5ab82e2950f and tested them separately, then together.

Production changes applied Interrupted child Completed follow-up, acknowledgment pending
Neither Ownership refusal Ownership refusal in both acknowledgment orderings
#177577 only Still fails Passes
#179099 only Passes Still fails in both orderings
Both Passes Passes

The interrupted-child case includes an independently written regression using the real OpenClaw monitor, client ownership runtime and releaseCodexBoundLiveThread. The follow-up cases and additional coverage came from the PR test suites. With both production patches applied, 55/55 selected tests passed across five files/two Vitest shards. That includes interrupted assignment restoration, protection during resumed inference before a delayed turn/started, running-sibling protection, cancellation selection, and retention/retry of undelivered results.

Scope: protocol-fixture regression tests against main plus the two production patches, not a full build of either exact PR head or a fresh live Gateway/model test. We did not deploy these changes. Our original incident had repeated ownership refusals despite no Gateway active run, but the historical logs do not identify the retained owner, so we cannot attribute that incident conclusively to either path.

I support getting this and #179099 merged. This fixes the redundant submission-protection path; #179099 covers interrupted-child protection. Testing only one would leave the other demonstrated lockout unfixed. No additional correctness finding from this validation.

@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 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 25, 2026
@steipete
steipete merged commit b9e3c3b into openclaw:main Oct 25, 2026
123 of 124 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…aw#177577)

* fix(codex): unblock parents after native follow-up completion

* test(codex): supply lifecycle timing option in custody proof

---------

Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
* fix(codex): unblock parents after native follow-up completion

* test(codex): supply lifecycle timing option in custody proof

---------

Co-authored-by: Peter Steinberger <[email protected]>

Adapted for release/2026.10.10: rewrote the custody-test fixture and regression changes against release's older raw-notification fixture (client as never, notify instead of finishTurn/item helpers) and release's createCodexThreadLifecycleTimingTracker({ enabled: false }) options form.
(cherry picked from commit b9e3c3b)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
* fix(codex): unblock parents after native follow-up completion

* test(codex): supply lifecycle timing option in custody proof

---------

Co-authored-by: Peter Steinberger <[email protected]>

Release adaptation: the stable custody test file predates main's client fixture shape; ported the new custody cases onto the stable fixture (client.client handles, explicit parent retirement on teardown).

(cherry picked from commit b9e3c3b)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
* fix(codex): unblock parents after native follow-up completion

* test(codex): supply lifecycle timing option in custody proof

---------

Co-authored-by: Peter Steinberger <[email protected]>

(cherry picked from commit b9e3c3b)

Adapted for 2026.9.x: the product hunk keeps 9.x's guarded clearTimeout. On 9.x the submission fixture lives in native-subagent-monitor.submission-lifetime.test.ts, so the regression case and the fixture's acknowledgePredecessor/detach parameters land there, using client.notify with the existing notification builders (no item/finishTurn test-client helpers on 9.x) and the fixture's existing client handle for the runtime calls.
@linancn
linancn deleted the codex/fix-native-submission-retention branch October 27, 2026 02:57
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: S 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.

4 participants