Skip to content

fix(codex): unblock replies after interrupted native children - #179099

Merged
obviyus merged 3 commits into
openclaw:mainfrom
wtfichigo:fix/codex-interrupted-parent-retention
Oct 23, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
wtfichigo:fix/codex-interrupted-parent-retention

Conversation

@wtfichigo

@wtfichigo wtfichigo commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #172837. Original fix and credit: @wtfichigo; their commit is preserved.

What Problem This Solves

After a native Codex child is interrupted, a later parent reply can fail with “Codex thread is claimed by active work; stop it first,” although the child's execution has ended. The interrupted assignment should remain resumable without keeping an idle parent pinned.

Why This Change Was Made

Release the monitor's parent retention once every child is terminal or settled without completion. Reacquire the same retention when execution resumes, including model admission before a delayed native turn-start notification. The existing cold-resume guard, assignment storage, cancellation ownership and completion delivery remain in place.

This complements the terminal-child fix in #175246; it does not duplicate the submission-owned-follow-up change in #177577. It changes no plugin SDK surface, configuration, permissions or storage schema.

Evidence

Observed built-Gateway comparison and focused checks.

  • Main twice: a real native child was admitted and completed with interrupted status; the parent finished; a public agent request with a changed benign extraSystemPrompt then failed at the protected-thread guard.
  • Candidate twice: the same sequence replied PONG_179099 on the original native parent, with the full interrupted-child assignment unchanged before/after.
  • A no-child control accepts the same instruction change on both arms.
  • Genuine pinned Codex 0.162.1 and real OpenAI Platform calls; no Gateway restart, fake client, held I/O, artificial child delay, killed child, private state edits, or fallback runtime.
  • 51 focused parent-retention, direct-authority, cancellation and custody tests passed; targeted formatting/lint passed. The restored-interruption regression fails on main at the same ownership guard.

Scope and Simplification

The existing monitor remains the only retention owner. Its acquisition helper replaces the old inline acquisition; the release path reuses the existing settled-child fact. No state, timers, retry mechanism or production API is added. An existing completion-custody fixture is shared rather than copied. Retained tests cover interrupted restore, resumed execution before its start notification, cancellation selection and custody.

Against the integrated base: production +27/-12 lines, tests/support +224/-41, documentation +4/-2. The small net production growth preserves reacquisition before resumed inference rather than weakening active-work protection.

User Impact

Conversations can continue without restarting the Gateway or discarding resumable child work. This does not prevent upstream connection outages.

Merge Danger

Two-way door: reverting restores the previous retention behavior without a data/config migration. The blast radius is Codex-native child interruption and resumed execution; an incorrect retention decision could either block idle parent replies or release a parent while child work is genuinely active.

@clawsweeper

clawsweeper Bot commented Oct 21, 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.

@wtfichigo
wtfichigo marked this pull request as ready for review October 21, 2026 05:59
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: M labels Oct 21, 2026
@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. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Release idle-parent protection after native child interruption and restore it when child execution resumes.

Example: A native child is interrupted, the parent finishes, and a later agent request changes extraSystemPrompt and requests PONG_179099.

  • Before: The parent request fails with “claimed by active work; stop it first.”
  • After: The original native parent replies PONG_179099 while the interrupted child's assignment remains unchanged.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused lifecycle repair with relevant live comparison, independent corroboration, meaningful regressions and the previous finding fixed.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The built candidate exercises native spawn, confirmed interruption and changed-instruction cold resume through public Gateway agent RPCs using Codex 0.162.1 and real OpenAI calls, producing PONG_179099 twice with assignments intact; the final head changes only test options, so that proof remains applicable.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An interrupted native child can leave an idle parent unable to answer later messages.
Reason: The bounded change restores conversation continuation without deleting resumable work; Related wording correctly leaves broader delivery work outside this PR.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current Codex interruption lockout. The previous type-error finding is resolved, and no blocking code findings remain; exact-head CI is still running.

Priority: P1
Reviewed head: 143eb6379d2f9051f05418c925fe80fa64833faa

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Codex plugin monitor consumes native execution notifications and recovered assignments, then coordinates parent subscription protection, resumable child work, and completion delivery.

flowchart TD
  A[Gateway agent request] --> B[Codex native parent]
  B --> C[Native child execution]
  C --> D[Subagent monitor]
  E[Saved assignments] --> D
  D --> F[Parent subscription protection]
  D --> G[Completion custody and delivery]
Loading

Technical review

Best possible solution:

Keep resumable assignments intact while the existing monitor protects the parent only during executable child work.

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

The supplied public-agent Gateway comparison reproduces the refusal twice on the pinned main baseline, and source inspection confirms the responsible retention logic remains on fetched main; no target code was executed during this review.

Is this the best way to solve the issue?

This is a focused owner-level repair: it reuses settledWithoutCompletion and the existing retention map, preserves the guard and durable assignment, and adds no competing state or policy.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 401ae11 adds extensions/codex/src/app-server/native-subagent-monitor.ts:424 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 401ae11b71cf; files: extensions/codex/src/app-server/native-subagent-monitor.ts)
  • Vincent Koc: Raw commit 4875b96 adds extensions/codex/src/app-server/native-subagent-monitor.ts:693 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4875b96d5b8d; files: extensions/codex/src/app-server/native-subagent-monitor.ts)
  • quqi1599: Raw commit 4caee42 adds extensions/codex/src/app-server/native-subagent-monitor.ts:2403 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 4caee42f6531; files: extensions/codex/src/app-server/native-subagent-monitor.ts)

PR surface

Source +15, Tests +183, Docs +2. Total +200 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 27 12 +15
Tests 5 224 41 +183
Docs 1 4 2 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 255 55 +200

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +27/-12; tests/support +224/-41 The production growth restores protection on resumed inference; test growth covers restoration and notification ordering while sharing the existing custody fixture.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A reproduced native-child lifecycle defect blocks subsequent parent replies in real Codex conversations.
  • 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 (3 earlier review cycles)
  • reviewed 2026-10-21T06:19:45.680Z sha 30e7861 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-22T06:03:56.374Z sha 30e7861 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-23T09:05:05.058Z sha 640938e :: needs changes before merge. :: [P2] [P2] Remove the retired recovery option from both new regressions

Reviewed October 23, 2026, 5:14 AM ET / 09:14 UTC (Revision 4).

@wtfichigo

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body with redacted live Gateway/native Codex proof for the unchanged candidate 30e7861a765f8cbf71fe5b96723499c4c2971b1b.

The exact-candidate run passed: real native interruption and restart restoration; an ordinary reply forced through same-parent cold resume with the full saved assignment unchanged; resumption of the same native child; the actual active-work guard rejecting another cold resume while that child continued running; and a successful reply after the child completed. The cold-resume trigger and terminal output are included in the body, separate from the earlier stable-backport Discord evidence.

No production code or installed Gateway changes were needed for this proof update. Exact-head CI remains green.

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

Copy link
Copy Markdown
Contributor

Independent validation in support of this fix. We reproduced the interrupted-child lockout with the exact claimed by active work; stop it first error; this patch clears it while retaining protection when execution resumes.

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 #177577 merged. They fix separate reproducible ways to lock a parent out; neither patch substitutes for the other. No additional correctness finding from this validation.

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 23, 2026
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Removed both retired recoveryPollDelaysMs properties in 143eb63, using the current monitor schedule rather than restoring the deleted test seam. Both affected files pass (2 parent-retention + 19 direct-authority tests), and targeted formatting passes. This is test-only: the twice-observed built-candidate native interruption/cold-resume comparison remains applicable because production source is unchanged. The earlier check-test-types failure was caused by these two stale constructor options, not an inherited failure; it has been repaired.

@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. 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 23, 2026
@obviyus
obviyus merged commit 42d4156 into openclaw:main Oct 23, 2026
122 of 123 checks passed
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Landed in 42d4156. Thanks @wtfichigo. An interrupted Codex child no longer blocks resuming its parent.

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

fix(codex): release the parent pin when an interrupted Codex child loses custody

When a native Codex child run was genuinely interrupted, it could keep its claim on the parent's execution pin after it no longer held executable custody. A later legitimate cold resume of the parent was then refused as already claimed. The pin is now released once the child has really lost custody; a child that still owns its work keeps it.

Evidence: built Gateway with the real Codex app-server and a real OpenAI provider run, child interrupted through a public RPC. On main the parent's cold resume with changed instructions was refused (twice); with this change the original parent resumes and replies with its full assignment unchanged (twice). Runs without a child behave as before.

Thanks @wtfichigo.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
fix(codex): release the parent pin when an interrupted Codex child loses custody

When a native Codex child run was genuinely interrupted, it could keep its claim on the parent's execution pin after it no longer held executable custody. A later legitimate cold resume of the parent was then refused as already claimed. The pin is now released once the child has really lost custody; a child that still owns its work keeps it.

Evidence: built Gateway with the real Codex app-server and a real OpenAI provider run, child interrupted through a public RPC. On main the parent's cold resume with changed instructions was refused (twice); with this change the original parent resumes and replies with its full assignment unchanged (twice). Runs without a child behave as before.

Thanks @wtfichigo.

Co-authored-by: Ayaan Zaidi <[email protected]>

Adapted for release/2026.10.10: applied the cancellation and direct-authority test changes to release's older fixture layout (local itemNotification/monitorFixture helpers, direct notify instead of completeTurn), with release's createCodexThreadLifecycleTimingTracker({ enabled: false }) options form and no readBinding on release's assignment store.
(cherry picked from commit 42d4156)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
fix(codex): release the parent pin when an interrupted Codex child loses custody

When a native Codex child run was genuinely interrupted, it could keep its claim on the parent's execution pin after it no longer held executable custody. A later legitimate cold resume of the parent was then refused as already claimed. The pin is now released once the child has really lost custody; a child that still owns its work keeps it.

Evidence: built Gateway with the real Codex app-server and a real OpenAI provider run, child interrupted through a public RPC. On main the parent's cold resume with changed instructions was refused (twice); with this change the original parent resumes and replies with its full assignment unchanged (twice). Runs without a child behave as before.

Thanks @wtfichigo.

Co-authored-by: Ayaan Zaidi <[email protected]>

Release adaptation: the stable child-unregister path keeps its thread-status revision collection. The main-only cancellation test file (descendant Stop, #169700) was not added; the shared custody fixture extraction is kept for the custody suite. New direct-authority and parent-retention cases use the stable lifecycle-timing options object and assignment-store factory signature.

(cherry picked from commit 42d4156)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
fix(codex): release the parent pin when an interrupted Codex child loses custody

When a native Codex child run was genuinely interrupted, it could keep its claim on the parent's execution pin after it no longer held executable custody. A later legitimate cold resume of the parent was then refused as already claimed. The pin is now released once the child has really lost custody; a child that still owns its work keeps it.

Evidence: built Gateway with the real Codex app-server and a real OpenAI provider run, child interrupted through a public RPC. On main the parent's cold resume with changed instructions was refused (twice); with this change the original parent resumes and replies with its full assignment unchanged (twice). Runs without a child behave as before.

Thanks @wtfichigo.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 42d4156)

Adapted for 2026.9.x: product hunks applied to 9.x call sites (applyNativeReceipts, unregisterChild keeps collectThreadStatusRevision; 9.x admitFollowupChild requires the thread id). The custody test refactor and cancellation test change are dropped (9.x has no descendant-cancellation test); the shared custody fixture file is added for the parent-retention case. The direct-authority case defines local itemNotification/interactionNotification helpers because the 9.x test support does not export them.
RomneyDa added a commit that referenced this pull request Oct 26, 2026
The #173018/#179050/#179099 ports awaited inventory and submission-store reads that are synchronous on 9.x (await-thenable), and grew native-subagent-inventory.test.ts past the 1000-line limit. Drop those awaits and move the delivery/restoration cases into native-subagent-inventory.restoration.test.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation 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: M 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.

3 participants