Skip to content

fix(codex): keep parents on the same thread after native child completion - #188698

Open
dubr1k wants to merge 1 commit into
openclaw:mainfrom
dubr1k:fix/codex-completed-child-tool-catalog
Open

dubr1k wants to merge 1 commit into
openclaw:mainfrom
dubr1k:fix/codex-completed-child-tool-catalog

Conversation

@dubr1k

@dubr1k dubr1k commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Current-main port (November 7, 2026)

The current-main completion-catalog port is now tracked in #194753, on top of #194748. It uses exact native completion custody and current executor ownership without copying the older release-specific schema/catalog overrides. The evidence below remains historical evidence for this PR head; it is not proof of the newer port or clearance of the earlier downstream native-dispatch review request.

Related: #153354

What Problem This Solves

Fixes a native Codex parent switching threads and losing access to its existing child when the last child's completion resumes the parent.

User Impact

A parent can receive its child's completion and send a follow-up to that same child without replacing the native parent thread or rebuilding its accepted tool catalog. No configuration or migration is required. This change does not address duplicate visible completion replies.

Why This Change Was Made

The existing catalog recovery path depends on live-child execution protection. That protection is correctly released before the last child's completion is delivered, leaving the automatic continuation exposed to a newly generated catalog.

Use the existing completion-delivery owner to identify an exact, currently in-flight completion for the same parent, child, requester session, run, and physical client. Only that delivery can recover the native thread's accepted catalog. Its authority is checked again after metadata is read. Runtime, home, transport, catalog fingerprints, and current tool-execution checks remain enforced; ordinary turns retain their existing behavior. No additional registry or SDK surface is introduced.

Codex's native contract was checked against rust-v0.164.0 (6aaac694803004a63c6f393d153c96d22521a6b9): thread/start accepts dynamic tools, while thread/resume does not replace them. A small existing parent-release loop moves to the existing parent owner without changing its behavior, keeping the monitor within the repository's source-size gate.

Published 2026.10.10: what is already fixed and what remains

The release notes credit #174900 for native catalog continuity. That is the upstream foundation this PR extends: protected parents can reuse their accepted declarations while current tool permissions remain enforced. It does not cover every completion lifetime. In the published tag's catalog guard, recovery still requires live-thread protection. The last child's completion releases that protection before delivery, so this automatic continuation can still miss catalog recovery and replace its parent thread.

This PR addresses that remaining completion-delivery interval through the existing owner, without weakening runtime fingerprints or granting execution rights from retained declarations. #188526 carries the corresponding release-branch change together with its WebChat-origin repair. The release notes therefore do not make this PR redundant.

Evidence

Additional published-release check — November 3, 2026

A selective port of this catalog change, the release-specific WebChat fix, and the remaining retirement error-class fix was applied to official 10.10 packages. On both macOS and Linux, a real-model authenticated WebChat run completed parent → child → automatic completion → same parent → follow-up to the same child. The parent and physical client stayed the same; the child returned its remembered marker. Shipped CLI history confirmed settlement. On Linux, an actual session_status call also succeeded after completion. These were observations of the combined installed port, not a new exact-head run of this PR or proof of all fallback paths.

The port's 50 focused tests passed, including composed checks for wrong-requester catalog denial, custody revoked during an awaited metadata read, and current executor restrictions after catalog recovery. The downstream native-dispatch denial and custody-reassignment trace requested in review is still missing. These checks do not clear that security/proof request. Accepted native metadata was inspected after each live run; no independent before-run catalog snapshot was taken. The exact-candidate evidence and its limits remain below.

  • Regression cases fail before the fix at the completion owner and catalog loader, then pass with it. The final changed suites pass 19 tests; related availability, execution-authority, and continuation suites pass 26 tests. The existing two parent-retention cases also pass after the owner extraction.
  • Codex production and test typechecks, targeted lint/format, git diff --check, source-size and test-line gates pass. The separate allocation grants exactly the change's 126 net regression-test lines; no shared ceiling or source-size baseline is raised.
  • Shared autoreview of the final range f3009a56907e34a42d0d453dddff8adb13de4f20..417d7e2113f065fb147bd458584dc72d9538b43f, including complete affected owners and authority context, found no actionable P0–P2 findings. Tests were executed separately, not by the reviewer.
  • pnpm build:runtime passes on 417d7e2 (82.3 s). A real-model, authenticated WebChat run on that exact source/build completes parent → child → automatic completion → parent continuation → follow-up to the same child. All three parent-ready events identify the same native parent and physical client; the child's follow-up returns its remembered marker. All 48 originally accepted functions match the final retained binding. The shipped CLI confirms the visible result and settled session.
  • Full local pnpm test:extension codex --maxWorkers=6: 5,368 passed, 3 failed, 17 skipped, across 441 executed files (481.57 s). Two failures are macOS process-inspection permission errors in unchanged transport-startup.test.ts; the third is the validation-watcher assertion in unchanged transcript-mirror-cleanup.test.ts. For the watcher failure, temporarily reversing this entire patch, verifying the parent-tree source bytes, and running the exact file through the supported Node 24 wrapper reproduces the same assertion on base f3009a5 (1 failed, 12.77 s). The patch was then restored and all changed-file hashes and clean HEAD verified. The process-permission signatures were also reproduced during the release baseline investigation; they have not been repaired here. Watcher root cause/order sensitivity remains undiagnosed. This full lane is not claimed as passing. No assertion, timeout, retry, skip, or expected-failure setting was weakened.

The live run used the pinned OpenClaw Bun 1.4.4 and Codex 0.164.0, isolated synthetic state, internal routing, and disabled model fallbacks. It produced two identical visible final replies, one for each child completion. It qualifies thread/catalog/child continuity, not exactly-once delivery, stale external routing, or general fallback behavior. The original accepted metadata was inspected after the run; no independent before-run catalog snapshot was taken.

Sanitized exact-candidate runtime proof
Exact-candidate main catalog-continuity proof
Source/build commit: 417d7e2113f065fb147bd458584dc72d9538b43f
Gateway runtime: pinned OpenClaw Bun 1.4.4 (openclaw-v1.4.4-20261026-191755ec11-webkit-b82bc917e9); identified from the running Gateway executable. Native runtime: workspace-pinned Codex 0.164.0.
Environment: authenticated WebChat client, isolated synthetic session, internal route, no external channels. Model fallbacks were disabled to fail closed.

One chat.send request was accepted; no manual continuation or model retry was sent.
Parent: 01a18e92-c25a-7e02-939a-b7ae5127109f
Child: 01a18e92-ef88-75d2-b7e3-14ee747f42e4 (native agent target /root/catalog_child)
Parent thread_ready: started, resumed, resumed; same parent and physical client throughout.
Parent native transcript: exactly one spawn_agent and one followup_task to that same child.
Child terminal results: FIRST_READY; FOLLOWUP_OK CATALOG_MEMORY_110.
Original accepted native catalog: 10 top-level declarations / 48 functions.
Accepted catalog fingerprint: sha256:a41950488f43f4dca21fd13f8e67488f888f443e901a80e45b2502112c1e9661
The final retained binding identifies the same parent and client and matches that accepted catalog fingerprint. The accepted session_meta record was inspected after the run; no separate before-run snapshot exists, so this is not a before/after digest comparison.

Shipped CLI read after settlement:
  OPENCLAW_STATE_DIR=<isolated-state> OPENCLAW_CONFIG_PATH=<isolated-config> pnpm openclaw gateway call chat.history --params '{"sessionKey":"agent:main:catalog-chain-proof","limit":100}' --json
Result: logical session catalog-chain-proof; visible CATALOG_CHAIN_OK 01a18e92-ef88-75d2-b7e3-14ee747f42e4; hasActiveRun=false; pendingInputs.total=0.

Observed limitation: two identical visible final replies, corresponding to the two child completion announcements. This run proves catalog/thread/child continuity; it does not prove exactly-once visible delivery, general fallback behavior, or stale external routing. The inherited spawn record in the child's rollout was not counted as a second spawn.

Cleanup: the proof client finished; the task-owned Gateway stopped cleanly after settlement and its listening port is closed. No production state or services were used. Private fixtures remain only until this sanitized evidence is published.

@clawsweeper

clawsweeper Bot commented Oct 30, 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR preserves a native Codex parent’s accepted tool catalog during its last child’s automatic completion.

Example: Native parent 01a18e92-c25a-7e02-939a-b7ae5127109f receives completion from child 01a18e92-ef88-75d2-b7e3-14ee747f42e4.

  • Before: Released execution protection prevents catalog recovery, allowing catalog drift to replace the parent thread.
  • After: Current completion custody permits catalog recovery, and the recorded live run follows up with the same child on the same parent.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused code with exact-head live continuity evidence and green CI; authority-boundary qualification remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A parent can switch native threads when its last child completes, preventing follow-up with that existing child.
Reason: The repair restores the established catalog-continuity contract for a concrete lifecycle gap; broader ordinary-turn catalog drift and duplicate replies remain outside this PR.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR addresses a real completion-continuity gap still present on main, and no introduced correctness defect was found.

Priority: P2
Reviewed head: 417d7e2113f065fb147bd458584dc72d9538b43f

Before merge

  • Add real behavior proof - Authority-chain proof required: the exact-head authenticated WebChat trace exercises completion delivery, catalog recovery, native parent reuse, and same-child follow-up successfully on Bun 1.4.4 and Codex 0.164.0. Supply a production-path trace showing rejection for a wrong requester and for custody revoked or replaced during preparation before subsequent native dispatch or unauthorized tool I/O; separate mocked boundary tests do not establish that composition. Redact credentials and private endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security concern: Qualify recovered declarations under narrower and revoked authority - The live trace demonstrates successful continuity; identity rejection, retirement, metadata-read revocation, and executor denial are exercised in separate tests rather than together through the new recovery path.
  • Resolve merge risk - Before merge, the contributor must qualify the new retained-custody recovery path against a wrong requester and revoked or replaced custody at downstream native and tool I/O.

Findings

  • [medium] Qualify recovered declarations under narrower and revoked authority — extensions/codex/src/app-server/native-subagent-completion-delivery.ts:65

Tests

  • Missing end-to-end proof: The supplied proof does not compose catalog recovery with wrong-requester rejection and custody revocation or reassignment before native dispatch and tool effects.
Agent review details

How this fits together

The Codex plugin turns host completion input into native parent continuations, recovering accepted declarations while building executors under the current turn’s authority.

flowchart TD
A[Native child completes] --> B[Completion delivery owner]
B --> C[Current custody check]
C --> D[Accepted native catalog]
D --> E[Parent continuation]
E --> F[Current execution checks]
F --> G[Native or tool effect]
Loading

Technical review

Best possible solution:

Keep catalog recovery in the existing completion owner and establish its denial and revocation behavior through the final effect boundary.

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

Current-main source shows execution protection ending before delivery while catalog recovery still requires that protection; the contributor records failing-before regressions, but this read-only review ran no reproduction.

Is this the best way to solve the issue?

The smallest complete repair uses the existing in-flight completion owner, preserves native declarations, and retains current executor checks; the parent-release extraction preserves the earlier intentional lifecycle behavior.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Qualify retained-custody recovery (recommended)
    The contributor should supply production-path evidence that a current completion succeeds, a wrong requester cannot recover the catalog, and revocation or replacement prevents subsequent native dispatch and unauthorized tool effects.

Provenance checked

  • Managed native catalog recovery changes intended behavior with a stated reason (c853069: Preserve accepted native declarations for protected managed parents while matching fresh executors under current authority.)
  • Terminal and interrupted parent retention keeps the original intent (4caee42: Release execution protection after children settle so pending delivery cannot block the parent continuation it needs.)
  • Completion custody and assignment identity keeps the original intent (41784ac: Preserve distinct reusable-child assignments and results, exact requester lifecycle, receipts, and original delivery ownership through recovery.)
  • Physical-client monitor sharing keeps the original intent (7f60f5f: Keep same-build module copies attached to the original physical client's monitor and ownership callbacks.)

Testing

Proof path: shipped entry point.

Security

Needs attention: No concrete bypass was found, but retained-custody catalog recovery still needs final-effect authority proof.

Evidence

Security concerns:

  • [medium] Qualify recovered declarations under narrower and revoked authority — extensions/codex/src/app-server/native-subagent-completion-delivery.ts:65
    The live trace demonstrates successful continuity; identity rejection, retirement, metadata-read revocation, and executor denial are exercised in separate tests rather than together through the new recovery path.
    Confidence: 0.9

What I checked:

Likely related people:

  • Paul Bohm: Raw commit c853069 adds extensions/codex/src/app-server/native-tool-catalog.ts:33 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c85306952ac7; files: extensions/codex/src/app-server/native-tool-catalog.ts)

PR surface

Source +119, Tests +126, Other +2. Total +247 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 147 28 +119
Tests 2 153 27 +126
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 10 302 55 +247

Review metrics

Metric Value Why it matters
Production versus regression tests Production +147/-28; tests +153/-27 Growth connects the existing completion and catalog owners without new persistent state; the tests cover matching identity, custody lifetime, metadata-read revocation, and ordinary-turn exclusion.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #153354
Summary: This PR repairs the last-native-child completion subset of the broader parent catalog-continuity problem.

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:

  • P2: A bounded native-child completion workflow can replace its parent thread and lose child continuity.
  • merge-risk: 🚨 security-boundary: The new recovery permission consumes retained completion custody across child and requester sessions; its downstream denial and revocation behavior needs composed final-effect evidence.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for a wrong-requester completion and show that custody revocation or reassignment prevents native dispatch and unauthorized tool I/O through catalog recovery.

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.

Reviewed October 30, 2026, 5:16 PM ET / 21:16 UTC.

@dubr1k

dubr1k commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Published 10.10 follow-up: #174900 is correctly listed in the release notes, but its protected-parent catalog recovery does not cover the last-child completion after execution protection has ended. The published tag still has that guard; the PR body now links the exact source and distinguishes the remaining interval from the upstream fix.

The body also records successful real-model continuation on macOS and Linux with a selective port to official 10.10 packages. This is additional combined-port evidence, not a replacement for exact-head proof. The requested downstream denial/reassignment qualification remains open; I am not asking to waive it. Please review this as the focused completion-lifetime follow-up to #174900, with #188526 as the release counterpart.

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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant