Skip to content

fix(codex): keep native children accessible after automatic completion - #155353

Open
stackingrockss wants to merge 2 commits into
openclaw:mainfrom
stackingrockss:fix/native-child-continuity-20260921
Open

stackingrockss wants to merge 2 commits into
openclaw:mainfrom
stackingrockss:fix/native-child-continuity-20260921

Conversation

@stackingrockss

@stackingrockss stackingrockss commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #155361

Current status — not merge-ready

Current-head review found a new P1: preserving a legacy catalog without message can make required message_tool_only delivery uncallable when the allowlist includes other tools. A production-selector + real native-resume + bridge probe now confirms this failure. No safe complete repair was established under the pinned native persisted-catalog contract; work is blocked, not merge-ready. The earlier local no-blocker review did not catch this.

CI run 35682737820: 38 passed, 2 failed, 18 skipped. All four continuity cases and baseline ratchets passed. Remaining failed native output-fidelity cases now expose bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted; the aggregate gate consequently fails. This establishes sandbox setup failure before intended command execution, not the exact host-policy cause. No sandbox weakening or test skipping is proposed.

Four-case hosted CI timings (disableMessageTool / legacyCatalog): false/false 19.314s, true/false 11.372s, false/true 9.964s, true/true 9.782s. Required-message delivery remains unresolved; the new production/native-boundary probe below confirms its failure. Earlier direct-protocol success must not be read as covering required delivery.

Confirmed required-delivery blocker at the production/native boundary

Using isolated Codex 0.154.0, the production compatibility selector preserves the legacy catalog without message. Direct execution of the real message tool succeeds through an isolated test channel transport, establishing that the transport itself works. Resuming the real native parent does not add message, even when supplied in dynamicTools; a model-requested message call then returns unsupported call: message, with zero bridge dispatches.

Simply excluding all required-delivery turns from compatibility causes parent replacement instead, reintroducing the active-child orphaning this PR is intended to prevent. Neither behavior is an acceptable complete repair.

Failing-first regression: the existing four cases passed; the new required-delivery case failed as intended after successful real transport execution. Total runner time 28.18s, cases 4.212 / 3.709 / 3.678 / 3.662 / 4.570s. The intentionally failing patch is retained as evidence and was not committed to the PR. The checkout remains clean at the stated head.

This probe crosses the production selector, real native resume, and bridge boundary, but is not full Gateway E2E. It proves a blocker, not successful upgrade delivery.

Recommended design decision: preserve the parent and pending delivery with an explicit retryable failure, then implement either native additive catalog migration or a separately designed, authorized, receipt-backed Gateway delivery mechanism. No such delivery mechanism or native migration is implemented by this PR. Do not merge the current repair as complete.

What Problem This Solves

Fixes native Codex children becoming inaccessible from their existing parent when a forced-message initial turn is followed by an automatic completion turn.

User Impact

The parent retains the same native task tree across this delivery-mode transition, so it can continue interacting with its existing child instead of silently starting a different parent thread.

Upgrade behavior: existing ordinary parents whose persisted catalog lacks only message retain that exact inherited catalog and fingerprint. This compatibility path is accepted only when every remaining tool declaration matches; unrelated catalog changes still rotate. Report-only completion isolation is preserved. This change does not recover task trees that were already separated.

Why This Change Was Made

The initial forced-message turn registered message, but an automatic completion turn omitted its declaration. That catalog difference rotated the native parent thread, leaving the existing child outside the new parent task tree.

New ordinary parents use a stable, registration-only message superset. Existing narrowed parents keep their compatible original registration. Actual execution still uses the current turn’s authorized tool set; registering a schema does not enable its execution. Restricted/subagent catalogs and runtime authorization remain unchanged.

Catalog preflight and shell-tool placement were extracted into focused helpers to stay within repository line-cap ratchets; no baselines or safety checks were relaxed.

Evidence

Current repair head: 389a4c5e8de373bda30eadcf85c6230855698e6d.

Regression and independent review

  • Legacy adoption regression demonstrated failing before the repair and passing afterward. Final matrix: 4/4 pass, covering new/legacy catalogs with disableMessageTool false/true, child continuity across completion/resume, and rotation for unrelated catalog changes. The native app-server/task tree in this regression is a protocol fake.
  • Final single-worker command: pnpm test -- extensions/codex/src/app-server/native-child-continuity.test.ts --maxWorkers=1 — 26.50s runner wall, 25.06s Vitest duration. This is integration-level coverage, not a lightweight unit test.
  • Repair verification: lifecycle + continuity 246 passed, dynamic registration + sandbox 128 passed, fingerprints 27 passed (overlapping runs; not summed as unique tests).
  • Independent review: no blocking code findings; 147 tests passed across continuity/fingerprints/dynamic builder and 217 lifecycle tests passed. Reviewer also reran the real native proof and pnpm check successfully. The reviewer’s nonblocking legacy+explicit-denial matrix suggestion was added and the final 4-case matrix rerun.
  • Final pnpm check:changed and git diff --check passed, including production/extension-test types, lint, line-cap/baseline guards, dead exports, boundaries, and runtime import cycles.

Real native evidence — bounded claim

An isolated Codex 0.154.0 app-server process, using a fresh disposable home/workspace and a scripted loopback model, spawned a real native child, resumed the same native parent, and successfully sent input to that child for both full and inherited narrowed catalogs. No live Gateway, existing owners, credentials, or production threads were used.

Redacted native receipt summary (synthetic test IDs replaced by labels):

full catalog:   parent=P1 -> spawn child=C1 completed
               resume=P1 -> sendInput receiver=C1 completed -> turn/completed
legacy catalog: parent=P2 -> spawn child=C2 completed
               resume=P2 -> sendInput receiver=C2 completed -> turn/completed

This is real native-process continuity evidence with direct protocol calls, not a live-model or full Gateway upgrade/completion-delivery end-to-end run. The production catalog-selection/adoption integration is covered by the explicitly mocked regression; no deployment or existing-thread recovery is claimed.

Hosted CI investigation

Original run: https://github.com/openclaw/openclaw/actions/runs/35678080498

  • Confirmed attributable failure: dynamic-tool-build.ts line-cap growth (841 → 845). Repaired without changing the baseline.
  • Two native output-fidelity cases failed with “Expected native command execution.” The fixture and direct native-client path bypass the repaired lifecycle. CI tested merge 8047216e; its fixture, native helper, Codex 0.154.0 pin, and lockfile integrity match the investigated snapshots.
  • Local head/base runs fail with a different signature: native exit code 1 from container bwrap namespace denial. That does not establish CI’s exact cause or prove it unrelated.
  • Added an assertion-message-only diagnostic to expose the native tool output already captured by the failing CI test. Assertions and sandbox behavior remain unchanged. Current-head CI exposes the Bubblewrap failure described above; it is not green.
  • Original CI timing: new continuity cases approximately 4.195s + 3.869s; extension bundle job about 212s. Updated four-case CI timings are recorded in Current status above.

AI-assisted implementation and independent local review. Requesting component-maintainer review of adoption behavior and the explicitly bounded native proof before landing. PR remains unmerged; no Gateway update/restart is part of this change.

@clawsweeper

clawsweeper Bot commented Sep 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.

@stackingrockss
stackingrockss marked this pull request as ready for review September 22, 2026 02:03
@stackingrockss

Copy link
Copy Markdown
Contributor Author

@steipete Could you review or route this native Codex continuity fix to the appropriate component maintainer? You are a recent author of the affected catalog builder. The repository requires owner involvement for material behavior changes, and this contribution needs maintainer review before landing.

The exact head is 8d3955f3de684c334c638ae0b39c0be4890c410d. Independent local review found no blocking issues (694 unique selected tests passed); the PR documents mocked native-tree proof and the one-time catalog migration hazard for existing parents with active children.

I cannot add a formal review request with my current repository permissions. Please route the required review and, once review and exact-head CI pass, use the repository-supported landing workflow. No approval or bypass is assumed.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

The Codex plugin stabilizes message-tool registration across completion turns, adopts matching legacy catalogs, and adds parent-child continuity regression coverage.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful continuity evidence and focused scope are outweighed by an acknowledged, unresolved required-delivery defect.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 7 items remain

Keep open: the contribution addresses a distinct continuity defect, but the previously reported required-delivery blocker remains unresolved. Newer main work preserves assignment records across rotation without establishing equivalent native parent-child access.

Priority: P1
Reviewed head: 389a4c5e8de373bda30eadcf85c6230855698e6d

Before merge

  • Add real behavior proof - Real Codex terminal receipts demonstrate direct native parent-child continuity, but successful required delivery through the changed production catalog selector is unproven; the recorded boundary probe instead fails before bridge dispatch. After repair, provide redacted terminal output or logs showing fresh and legacy parents retaining child access and completing required delivery. Screenshots or recordings also count when they show that behavior; remove private addresses, endpoints, keys, and user details. Updating the PR body should trigger re-review, or ask a maintainer to comment @clawsweeper re-review. Existing-state catalog compatibility remains insufficient independently of general runtime proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep required message delivery callable during legacy adoption (P1) - For a saved catalog lacking message, a message_tool_only turn with additional allowed tools passes this guard because isMessageOnlyCodexSourceReply recognizes only the exact single-tool allowlist. Adoption then removes message to match the saved fingerprint. Native resume cannot add that declaration, so required message calls fail before bridge dispatch. The PR body's production/native probe confirms this result. This previously raised blocker remains unfixed; preserve continuity and required delivery together.
  • Resolve merge risk - Upgrading a legacy parent whose catalog lacks message can preserve child continuity while making required channel delivery impossible; excluding adoption instead can replace the parent and defeat continuity.
  • Complete next step - Resolve the legacy required-delivery defect, provide successful existing-state compatibility proof, and refresh the currently conflicting branch against main.
  • Improve patch quality - Repair legacy adoption without dropping required delivery or replacing the parent to hide the failure.
  • Improve patch quality - Provide successful production-selector/native-boundary proof for fresh and legacy parents, including denied message execution on unauthorized turns.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Keep required message delivery callable during legacy adoption — extensions/codex/src/app-server/thread-lifecycle-catalog.ts:38-44
Agent review details

How this fits together

The Codex plugin translates OpenClaw turn tools into native Codex thread catalogs. Catalog compatibility determines whether a parent resumes its existing task tree, while the separate execution bridge controls which tools the current turn can run.

flowchart TD
  A[OpenClaw turn and delivery policy] --> B[Tool registration builder]
  B --> C[Catalog compatibility selector]
  D[Saved parent catalog] --> C
  C --> E[Resume parent or replace thread]
  E --> F[Native child task tree]
  A --> G[Authorized execution bridge]
  E --> G
  G --> H[Channel delivery]
Loading

Technical review

Best possible solution:

Keep native child access and required delivery compatible together, preserving pending results with an explicit retryable failure whenever the existing native catalog cannot support delivery.

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

Yes: a legacy fingerprint without message, required message delivery, and an allowlist containing other tools reach the faulty adoption branch. The contributor records the matching native rejection; this review did not execute it.

Is this the best way to solve the issue?

No: stable registration is useful, but silently adopting a catalog that cannot perform required delivery is incomplete; merely disabling adoption would reintroduce parent replacement.

Full review comments:

  • [P1] Keep required message delivery callable during legacy adoption — extensions/codex/src/app-server/thread-lifecycle-catalog.ts:38-44
    For a saved catalog lacking message, a message_tool_only turn with additional allowed tools passes this guard because isMessageOnlyCodexSourceReply recognizes only the exact single-tool allowlist. Adoption then removes message to match the saved fingerprint. Native resume cannot add that declaration, so required message calls fail before bridge dispatch. The PR body's production/native probe confirms this result. This previously raised blocker remains unfixed; preserve continuity and required delivery together.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Repair the legacy delivery boundary (recommended)
    Establish a supported path that retains the parent and delivers required replies, then prove fresh and legacy behavior through the production selector and native boundary.
  2. Pause this implementation
    Keep the paired bug open while a compatible native-catalog or existing delivery-owner repair is established.

Security

None.

Evidence

What I checked:

  • Pinned introduction: The introduced delta adds stable message registration and legacy catalog adoption. The checkout is the verified original head, with recorded parent 8d3955f; no pinned test merge is available, so no base-drift deletion claims are made. (extensions/codex/src/app-server/thread-lifecycle-catalog.ts:37, 389a4c5e8de3)
  • Required-delivery trigger remains: Legacy adoption excludes only the exact message-only allowlist. A message_tool_only turn allowing additional tools still enters adoption, which removes message when the narrowed catalog matches the saved fingerprint. (extensions/codex/src/app-server/thread-lifecycle-catalog.ts:39, 389a4c5e8de3)
  • Native dependency contract inspected: The PR explicitly depends on native app-server resume retaining persisted dynamic declarations. Personally inspected ThreadResumeParams handling, resume_thread_with_history, and session initialization: resume does not accept replacement dynamic tools, and session initialization restores declarations from history. GitHub verified this dependency commit belongs to openai/codex. (codex-rs/core/src/session/mod.rs:720, 6b9826e3aa83)
  • Captured native proof and contrary result: The supplied body records real Codex 0.154.0 parent-child continuity through direct native calls. Its production-selector/native-resume probe instead reports unsupported call: message and zero bridge dispatches after independently successful transport execution. This proves the acknowledged blocker, not successful required delivery. The captured context sourceRevision is b8080452b83192740dc1acac9963859d28d9f853159de11c987d671c5a3fe687. (389a4c5e8de3)
  • Current-main necessity check: Current main still only clears disableMessageTool for durable registration; it does not force the stable delivery-mode superset introduced here. Its lifecycle still compares catalog fingerprints. No same-repository merged PR was established as fixing the exact requested continuity behavior. (extensions/codex/src/app-server/dynamic-tool-build.ts:169, 27ba9720f2c5)
  • Merged adjacent repair: GitHub confirms fix(codex): preserve native assignments across parent rotation #160952 merged as 5367527. Its documented repair retains assignment and completion records during parent replacement; it does not establish same-parent native child access or resolve this branch's legacy message registration failure. (extensions/codex/src/app-server/thread-lifecycle-run.ts, 5367527c2717)

PR surface

Source +88, Tests +234. Total +322 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 139 51 +88
Tests 2 235 1 +234
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 374 52 +322

Review metrics

Metric Value Why it matters
Production versus test growth production net +88 lines; tests net +234 lines Production growth is explained by focused catalog-adoption helpers and stable registration, with separate regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #155361
Summary: This PR is the candidate repair for the explicitly paired continuity issue; assignment retention and parent-wake semantics overlap without establishing equivalent fixes.

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 proposed legacy adoption can break required channel delivery in an existing native-child workflow.
  • merge-risk: 🚨 compatibility: Existing saved catalogs lacking message need a compatible upgrade path that preserves both parent access and delivery.
  • merge-risk: 🚨 message-delivery: The introduced selector can remove the required message declaration before native dispatch.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 (5 earlier review cycles)
  • reviewed 2026-09-22T02:09:51.969Z sha 8d3955f :: needs real behavior proof before merge. :: [P1] Preserve existing parent bindings during catalog adoption
  • reviewed 2026-09-22T03:26:16.594Z sha 389a4c5 :: needs real behavior proof before merge. :: [P1] Keep required message delivery callable during legacy adoption
  • reviewed 2026-09-22T04:02:20.229Z sha 389a4c5 :: needs real behavior proof before merge. :: [P1] Keep required message delivery callable during legacy adoption
  • reviewed 2026-09-26T22:58:34.084Z sha 389a4c5 :: needs real behavior proof before merge. :: [P1] Keep required message delivery callable during legacy adoption
  • reviewed 2026-09-28T21:23:12.343Z sha 389a4c5 :: needs real behavior proof before merge. :: [P1] Keep required message delivery callable during legacy adoption

Reviewed October 6, 2026, 10:52 PM ET / October 7, 2026, 02:52 UTC (Revision 6).

@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper-recovery-stuck rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. P1 High-priority user-facing bug, regression, or broken workflow. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper-recovery-stuck P2 Normal backlog priority with limited blast radius. labels Sep 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Native Codex parent loses child access after automatic completion changes tool catalog

1 participant