fix(codex): preserve native subagent results after parent cleanup#102060
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 2:06 AM ET / 06:06 UTC. Summary PR surface: Source +157, Tests +183, Other +8. Total +348 across 8 files. Reproducibility: yes. Current-main source provides a high-confidence path through rollout-dependent recovery and unbounded non-durable retries, while the branch's live run demonstrates exact detached delivery and fresh-monitor history recovery after the fix; this read-only review did not execute current main. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the exact history-based rewrite after Codex lifecycle-owner sign-off and normal CI resolution, preserving one canonical app-server recovery and delivery path without restoring rollout parsing or parallel cleanup fallbacks. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source provides a high-confidence path through rollout-dependent recovery and unbounded non-durable retries, while the branch's live run demonstrates exact detached delivery and fresh-monitor history recovery after the fix; this read-only review did not execute current main. Is this the best way to solve the issue? Yes. Direct inspection of pinned Codex source confirms app-server history is the narrow transport-independent source of truth, and the patch removes duplicated rollout discovery and bespoke cleanup without adding public API or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f6d11d0e29a2. Label changesLabel justifications:
Evidence reviewedPR surface: Source +157, Tests +183, Other +8. Total +348 across 8 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (6 earlier review cycles)
|
9040d9c to
e6d5c68
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2125be861f
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This comment has been minimized.
This comment has been minimized.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer review + land-ready proof (head Verdict: best-fix. History-backed recovery via Codex contract verification (sibling
Validation:
Improvements added on top (
Known gaps: none blocking. Recovery polling is unbounded by design (accepted trade-off: losing results is worse; client close still disposes cleanly). |
b022768 to
3faf684
Compare
…mpletions Adds an opt-in live lane (OPENCLAW_LIVE_CODEX_NATIVE_SUBAGENT=1) that spawns a real native subagent through the app-server with an OpenAI key, proves the parent turn completes before detached delivery, and recovers the same result from thread/read history with a fresh monitor. Registers both codex opt-in live files in the release shard optional-env map and restores the registered-child user-spoof regression test dropped by the monitor rewrite.
The prepare gate owns CHANGELOG.md for releases; release-note context lives in the PR body and squash message instead.
e48dd54 to
9d8c179
Compare
|
Landed as 401ae11 (squash, admin merge on maintainer instruction). Merge context: full PR-side proof was green — Testbox focused suites + |
…enclaw#102060) Codex native subagent results now survive parent cleanup, app-server persistence races, resumptions, and transient delivery failures. The monitor treats app-server thread/read and thread/turns/list history as canonical recovery state (works on non-stdio transports), retains the shared physical client only while detached children need monitoring, fences stale reads across lifecycle changes, keeps interrupted children resumable, preserves multi-agent V2 subAgentActivity lineage, and bounds terminal delivery retries with a durable failed state. Removes rollout-file discovery, transcript parsing, periodic whole-client rescans, and the deferred one-shot cleanup path. Adds an opt-in live E2E lane (OPENCLAW_LIVE_CODEX_NATIVE_SUBAGENT=1) proving detached delivery and history-only recovery against a real app-server with an OpenAI key, restores the registered-child user-spoof regression test, and registers both codex opt-in live files in the release shard optional-env map. Closes openclaw#97593 Related: openclaw#93313
Closes #97593
Related: #93313
What Problem This Solves
Fixes issues where Codex native subagent results could be lost after the parent turn cleaned up its app-server client, stale local rollout data could win after a child resumed, and permanently non-durable delivery could rerun the parent forever. The local-rollout recovery path also could not cover non-stdio app-server transports.
Why This Change Was Made
The monitor now treats the app-server's
thread/readandthread/turns/listresponses as canonical recovery state while preserving streamed terminal messages as the fast path. It retains the shared physical client only while detached children need monitoring, fences stale reads across lifecycle changes, keeps interrupted children resumable, and bounds terminal delivery retries with a durable failed state on exhaustion.This removes rollout-file discovery, transcript parsing, periodic whole-client task rescans, and the bespoke deferred one-shot cleanup path.
User Impact
Codex native subagent completions remain reliable across parent cleanup, websocket/non-local transports, app-server persistence races, resumptions, and transient system errors. Permanently non-durable parent delivery now stops after bounded retries instead of waking the parent indefinitely.
Evidence
turn/completeditems.pnpm test extensions/codex/src/app-server/native-subagent-monitor.test.ts extensions/codex/src/app-server/native-subagent-task-mirror.test.ts extensions/codex/src/app-server/run-attempt-thread-cleanup.test.ts extensions/codex/src/app-server/shared-client.test.ts— 88 passed.pnpm check:changed— passed.pnpm test:extension codex— 2,008 passed across 96 test files.AI-assisted implementation and review. No agent transcript attached.