Native subagent completion fails to wake an unloaded parent with wake_on_agent_messages enabled
What version of the Codex App are you using (From “About Codex” dialog)?
26.1120.50957
What subscription do you have?
ChatGPT Pro ($200/month)
What platform is your computer?
Microsoft Windows 11 Home 10.0.26300 x64
What issue are you seeing?
Summary
A persistent parent chat delegates work with collaboration.spawn_agent and finishes its turn normally. The app-server unloads the idle parent while the child is still running.
When the child succeeds, the official Codex core logs a terminal result addressed to the correct parent thread. We observed no matching receive and no new parent turn during the next 30 seconds.
In the original incident, the next parent turn came from a user message 3 hours and 22 minutes after the child completed.
A standalone, credential-free fixture independently reproduces the defect on the signed stock executable.
A downstream fix restored the native parent and started exactly one follow-up turn 48 ms after child completion in a separate controlled real-MCP run.
The parent model should not be responsible for keeping its own orchestration runtime alive.
Environment
- Windows x64.
- Signed OpenAI Microsoft Store package:
OpenAI.Codex_26.1120.6357.0_x64__2p2nqsd0c76g0. - Bundled core:
0.171.0-alpha.13.2. - Upstream source revision:
ad9d659a8491fc5169a00dcf7b7e6ca8a87adf69. - Stock executable SHA-256:
2A1EC3F1DD463FD30224BE4C0C67D3FE83D3D863A3D7539CCAD366952436D2AA. - Reproduction configuration: native
multi_agent_v2,wake_on_agent_messages=true,thread_unload_delay_secs=2, anddefer_mailbox_preemption=truein the standalone fixture. The effect of varying the latter flag was not isolated. - Fixed downstream executable SHA-256:
161F41D4A7436438E5CA57248CB3C33283587080129419329DE8E73254F85251.
Observed results
| Executable and workload | Result sends / matching receives | New parent turns |
|---|---|---|
| Official stock, attached standalone fixture | 1 / 0 | 0 in 30 s |
| Official stock, real long-running MCP QA job | 1 / 0 | 0 in 30.005 s |
| Fixed downstream, same native delegation path and real MCP QA workload | 1 / 1 | Exactly 1, started 48 ms after child completion |
The stock executable reproduced the failure without our downstream orchestration or anti-polling changes. The app-server and its stdio connection remained alive throughout the controlled reproduction.
This is a runtime lifecycle and orchestration liveness defect, not a model behavior or prompting issue.
What steps can reproduce the bug?
Standalone reproduction
The attached reproduction package has been successfully tested against the official signed Windows Store executable.
It uses an isolated Codex home and a deterministic loopback inference provider. It requires no API credentials, npm installation, external MCP service, project-specific infrastructure or Desktop restart.
Execution instructions
- On Windows with Node 24 and the affected Store build installed, open PowerShell in a checkout of upstream revision
ad9d659a8491fc5169a00dcf7b7e6ca8a87adf69. - Extract
native-child-wake-repro.zipinto a directory namedwake-reproin that checkout. - Run:
$pkg = Get-AppxPackage -Name OpenAI.Codex | Where-Object { $_.Version -eq [version]'26.1120.6357.0' }
$exe = Join-Path $pkg.InstallLocation 'app/resources/codex.exe'
$out = Join-Path $env:TEMP ('codex-wake-' + [guid]::NewGuid())
node ./wake-repro/stock-wake-repro.mjs --binary "$exe" --catalog ./codex-rs/models-manager/models.json --evidence "$out"
Get-Content -Raw (Join-Path $out 'result.json')
Reproduction sequence
The script performs the following steps:
- Start the official Codex app-server over stdio with an isolated Codex home.
- Enable native
multi_agent_v2,wake_on_agent_messages=trueanddefer_mailbox_preemption=true. Setthread_unload_delay_secs=2. - Start a persistent Desktop-compatible parent thread and delegate work using native
collaboration.spawn_agent. - Let the parent complete its original turn while the child is still working.
- Unsubscribe the last client from the parent using
thread/unsubscribe. - Observe
thread/closedand confirm through a single non-subscribingthread/loaded/listrequest that the original parent is unloaded while the original child remains loaded. - Release the child's unique terminal result and let it complete successfully.
- Send no further client RPCs, resume requests or user messages.
- Observe the native communication logs and persisted parent rollout for 30 seconds.
Verified stock outcome
- Outcome:
missing-wake-reproduced - Terminal result sends: 1
- Matching receives: 0
- Automatic parent follow-up turns: 0
- Result communication ID:
01a21fab-e071-7c30-8f0d-8eb7aa94610c
Read outcome in result.json. The fixture exits successfully for either recognized behavior.
The outcome is classified from persisted follow-up turns and the ACK; the native communication logs in the same result must be examined separately for matching send/receive events.
The same failure was independently observed with a real long-running MCP QA job using native spawn_agent on the official executable.
What is the expected behavior?
With wake_on_agent_messages enabled, a terminal native subagent result should automatically restore an eligible parent thread that has been unloaded through ordinary idle eviction.
For a single terminal result:
- Restore the original parent thread under its existing thread identity.
- Deliver the correct result once.
- Start exactly one automatic follow-up turn.
- Preserve the original completed turn.
- Preserve session isolation, execution policies and permission boundaries.
- Respect existing explicit interruption and cancellation semantics.
Multiple pending results may legitimately be coalesced into a single follow-up turn, provided that no result is lost or processed twice.
A Desktop subscription, manual resume, additional user message, continuously active parent turn or parent-side polling should not be required.
Thread residency should be a resource-management concern, not a prerequisite for orchestration correctness.
Please make native result delivery and automatic wake-up independent of eligible parent thread residency and Desktop subscriptions, while preserving existing cancellation and execution-policy guarantees.
Additional information
Failure mechanism
The stock terminal-result path in codex-rs/core/src/agent/control/completion.rs passes trigger_turn=false.
Delivery can enqueue mail for an unloaded recipient and record a send. A receive is recorded when the recipient takes the message.
In this case, the parent's session loop had exited and nothing restored it to consume the result.
The missing lifecycle transition is:
Terminal result queued
-> Restore unloaded parent
-> Consume result
-> Schedule follow-up turn
The trace establishes a missing wake and receive. The eventual fate of the queued entry is unknown.
Downstream fix
Our downstream fix retains the original native controller, its mailbox signal receiver, and the parent resume context across idle unload.
Incoming mail triggers restoration under the same per-thread lock used by manual resume. The restored session consumes its original inbox.
The implementation separates the lifetime of agent communication from the lifetime of the loaded parent session.
End-to-end validation
Fixed run, 28 November 2026, UTC:
00:53:15.329 Original parent turn completed
00:53:19.739 Confirmed parent unloaded; child still loaded
00:53:37.976 Child task completed successfully
00:53:37.979584 Native terminal result sent
00:53:38.018739 Matching result received
00:53:38.024 Automatic parent follow-up turn started
Correlated identifiers:
- Parent thread:
01a21fa4-5c5e-7532-b2d1-2244a95de481 - Result communication:
01a21fa4-b63b-7982-9f3f-e978ad275744 - Follow-up turn:
64e945a7-ff7b-4894-8463-b7f9136c88da - Final acknowledgment:
QA_ACK 412c5981-6bf8-40bb-a37c-7efab4c74cc9
Both real-QA runs used native spawn_agent without an orchestration binding or custom wake callback.
The 48 ms measurement is from child task completion to the start of the follow-up turn in this controlled run, not a production model latency benchmark.
Additional targeted acceptance tests
| Scenario | Result | Observed outcome |
|---|---|---|
| Native upstream-path parity | PASS | One matching send and receive, exactly one automatic follow-up turn, correct job acknowledgment, 48 ms wake latency |
| Concurrent manual resume and automatic wake | PASS | Manual resume returned the same active turn; one receipt and ACK; no deadlock |
| Two simultaneous child completions | PASS | Both results acknowledged once in one turn, started 35 ms after completion |
Explicit turn/interrupt of an active parent turn |
PASS | Parent remained unloaded; no new turn or receive in 30.015 s |
These are bounded acceptance observations, not a proof for all interleavings. The interrupt test does not establish a cancellation contract for already completed dormant turns.
Scope and known limitations
The attached wake-only patch is provided as a reference implementation, not a ready-to-merge upstream fix.
It passed git apply --cached --check against the upstream pin but uses two downstream helpers, DelegationHandoffMode::restored and has_deferred_turn_input().
We have not compiled it against pristine upstream.
Source review also identified two downstream limitations:
- Execution-policy freshness during automatic cold resume: A stricter on-disk policy introduced during dormancy may not be reflected by the captured policy manager.
- Dormant-waiter cleanup: After a permanent restore failure, a retained waiter may outlive an embedded app-server if its host runtime continues.
Neither condition was reproduced during the acceptance runs. These require attention before broader deployment or upstream integration.
The successful tests kept the same app-server process alive. Recovery after full app-server termination and injected transient storage failures were not tested.
The stock bug reproduction is independent of the downstream fix and its limitations.
Attachments
1. Standalone reproduction
A self-contained, sanitized reproduction package tested against the official signed Windows Store executable.
- Executable Node.js reproduction script and instructions.
- Isolated Codex home and deterministic local inference provider.
- No credentials, external MCP services, npm dependencies or project-specific infrastructure.
- Independently reproduces the missing wake without downstream modifications.
2. Supplementary validation
The complete technical acceptance report, including:
- Executable identities and SHA-256 hashes.
- Correlated thread, turn, job and communication IDs.
- Exact timestamps and measured wake-up latencies.
- All four successful targeted acceptance tests.
- Source-review findings, known limitations and upstream portability considerations.
3. Reference implementation
An isolated Rust-core patch implementing event-driven restoration of unloaded parent threads.
The implementation has been validated end-to-end in our downstream Codex build, including all four targeted acceptance scenarios.
Wake-only diff SHA-256:
A3C139B045E39FB98DA5E076DBD2AA73A56CF176CEFDE579C861DDD37DA17D4D
The patch is provided for technical review and adaptation, subject to the upstream portability and hardening limitations documented above.
Related issues
- #61901 — Automatic parent wake-up for independent
create_threadassignments. - #63464 — Runtime-enforced event-driven orchestration and deterministic parent turn completion after delegation.
Unlike those feature requests, this issue reports a reproducible defect in the existing native spawn_agent wake-up mechanism on an official, unmodified Codex executable.
Distinction from #36493
Although #36493 also concerns native multi-agent communication, it describes a materially different failure mode.
- #36493 concerns parent-to-child task delivery: the child is successfully activated but receives an empty task payload. The reporter explicitly confirms that child-to-parent final-answer delivery works.
- This issue concerns child-to-parent terminal result delivery after idle parent eviction. The child receives its assignment, executes it successfully, and emits a correctly addressed terminal result. However, the unloaded parent is not restored, the result is not consumed, and no follow-up turn starts.
The distinguishing failure in this report is the missing lifecycle transition from pending mailbox communication to parent session restoration, rather than missing message content.
The two reports therefore concern different communication directions, failure conditions, and runtime behavior. The evidence in #36493 does not account for the unloaded-parent wake-up failure demonstrated here.
Update: Both downstream hardening findings resolved
Following the initial bug report and publication of the reference implementation, we addressed both outstanding source-review findings in our downstream Codex core.
All three targeted regression checks passed on the final hardened implementation.
Validation results
| Test | Result | Observed behavior |
|---|---|---|
| Execution-policy freshness | PASS | A command permitted before parent eviction was correctly denied under a newly tightened execution policy after automatic restoration. The child result was still acknowledged exactly once. |
| Dormant waiter cleanup | PASS | Following a permanent restore failure, the dormant registration remained available for manual recovery while the app-server was running. App-server shutdown terminated the waiter and released its registration, while the underlying Tokio runtime remained operational. |
| Native wake-up regression | PASS | The unloaded parent was automatically restored and started exactly one follow-up turn 55 ms after child completion, acknowledging the correct job ID without polling or manual intervention. |
Security semantics
Automatic restoration now reloads current configuration sources and execution rules, reconciles them with the original security context, and incorporates safely representable policy restrictions.
If the original and current permissions cannot be safely reconciled, automatic execution is suppressed. The unread result remains pending for manual recovery while the owning app-server is alive.
This deliberately prioritizes execution-policy integrity over automatic continuation.
Lifecycle semantics
Dormant waiter registrations are now tied to the lifetime of their owning app-server.
Permanent restoration failures retain manual recovery capability while the server remains operational, but shutdown deterministically terminates the waiter and releases its registration.
No arbitrary result-expiration TTL or parent-side polling was introduced.
Hardened executable
- Version:
codex-cli 0.171.0-alpha.13.2 - Platform: Windows x64
- Upstream pin:
ad9d659a8491fc5169a00dcf7b7e6ca8a87adf69 - Downstream commit:
b2d8078fdc47382b18cfdedb24d3fe8e1082954e - Source tree:
efb1073f6742e9b3b51fff16b4f91ec783870e0c
Executable SHA-256:
367D947CF3854FECFF13D31C835D70EB1D8A0E2B43AD788FFA5BB5845001F9CA
Updated reference implementation
The attached hardened wake-only patch supersedes the reference patch provided in the original issue.
It contains the unloaded-parent wake-up fix and both subsequent security and lifecycle hardening changes.
Patch: codex-parent-wake-fix-v2-hardened.patch
Base:
ba7a54d5168f404c0f31f79d20cf2fbf950a861b
SHA-256:
55C15A83D9B2538311E3A608FCABCC47B36CD8722EC49E5BE59FE2F2A47BC72E
The patch is provided as a technical reference implementation, not a merge-ready upstream contribution. It retains the previously documented downstream dependencies.
Hardening acceptance report
The attached hardening-acceptance.md contains the complete technical acceptance results, including:
- Correlated communication and turn IDs.
- Execution-policy tightening verification.
- Embedded app-server shutdown verification.
- Native wake-up regression results.
- Build and source-tree identities.
- Patch bases and SHA-256 hashes.
- Remaining scope limitations.
Validation boundaries
The three additional targeted checks passed on the final hardened implementation. The earlier four acceptance scenarios were validated on the preceding downstream build.
These results do not establish exhaustive concurrency correctness, qualification of every earlier scenario on the final build, or inbox recovery following full app-server termination.
A standalone upstream-only implementation has not yet been compiled or qualified.
The original independent stock-binary reproduction remains unchanged and establishes the upstream defect independently of all downstream modifications.
Conclusion
Both previously documented downstream hardening findings have been addressed and validated through targeted regression tests.
The final native regression demonstrates automatic continuation of an eligible unloaded parent within 55 ms of child completion, without polling or manual intervention, while respecting the tested execution-policy and lifecycle constraints.
The parent model should not be responsible for keeping its own orchestration runtime alive.