fix: deliver a finished Codex subagent's result while a sibling is still running (#190999)
Root cause: extensions/codex/src/app-server/native-subagent-completion-delivery.ts:97 (main 4f8b68e647af) only holds a finished native child's result while the parent has a foreground owner, so a detached parent that the monitor itself keeps protected for a still-running sibling (native-subagent-monitor.ts:2342) is treated as deliverable; the wake turn then cold-resumes the parent through releaseCodexBoundLiveThread, which refuses while that protection is held (thread-lifecycle-warm.ts:247-259), and the retry budget is spent until the result is retired undelivered.
Fixes #188422
Thanks @esqandil for the detailed report and source trace, and @gouyu-hou for the fix this PR builds on.
## What Problem This Solves
A Codex parent that spawns two native subagents and yields loses the result of the subagent that finishes first while the other is still running. Every attempt to wake the parent with that result fails with "claimed by active work" / "still has background work", and when the slower subagent runs longer than the retry window (about 9 minutes) the finished result is retired with "Native subagent completion retired without delivery" and never reaches the conversation.
## User Impact
A finished native subagent's result now reaches the parent exactly once, right after its last running sibling finishes, instead of being dropped. Single-subagent runs and foreground parents behave as before.
## Why This Change Was Made
Codex queues a child's completion into the parent's mailbox without starting a parent turn (codex-rs/core/src/agent/control/completion.rs:117 `trigger_turn: false` in `notify_parent_of_terminal_turn`, sent through control.rs:167 `send_inter_agent_communication`, rust-v0.169.0), so OpenClaw has to start the wake turn itself. That turn needs the parent subscription the monitor deliberately keeps protected while any sibling still runs. The delivery owner now holds detached results while that monitor retention exists, without spending retries or settling custody, and the monitor re-drives held results from the release it already performs when the last sibling settles.
The previous revision of this PR held results only when the parent had no idle subscription. The end-to-end run below shows that predicate does not hold: the parent kept an idle subscription, yet the wake turn still took the cold-resume path (its thread config differs from the user turn's) and was refused. Holding whenever the monitor's own retention protects the parent is the rule the lifecycle actually enforces. The trade-off: when a warm continuation would have worked, the first result now waits for the sibling instead of arriving early.
Separate slice, not covered here: #192214 (ordinary follow-up turns that need a fresh thread while children still retain the parent).
One existing expectation changes on purpose: when a later foreground turn calls `sessions_yield` while the sibling still runs, the finished child is now listed as `completing` (its result is held, not yet delivered) instead of being treated as already delivered.
## Evidence
Observed Gateway log and reply lines for every run below: https://github.com/openclaw/openclaw/pull/190999#issuecomment-6976733723
Built Gateway (dist) with the real bundled Codex app-server 0.169.0 against a local ChatGPT-backend fixture. The parent calls Codex's own `collaboration::spawn_agent` twice and yields; the short child answers at once, the long child holds its model response for 10 minutes.
- main 4f8b68e647af: short child's announce refused ("still has background work after waiting for cleanup") at every retry, then `Native subagent completion retries exhausted` and `Native subagent completion retired without delivery`; the parent only ever answered `PARENT-SAW:C2_DONE` (C1 lost).
- previous PR head 5301493 (merged with main), 90 s sibling: the same refusals; C1 reached the parent only on the last retry, about 9 minutes after it finished.
- this head: no announce attempt while the sibling runs, no refusals; both results reach the parent once after the sibling finishes.
- control, one child: delivered once on both base and this head.
Regression: `native-subagent-monitor.parent-retention.test.ts` fails on main (delivery called 7 times while the sibling runs) and passes here; `run-attempt.native-followup-custody.test.ts` now reports the held result as `completing`. 124 focused native-subagent tests pass.
Merge danger: two-way door, no stored state or contract change; a revert restores the old retry behavior. Blast radius: Codex-harness native subagent completion delivery for detached parents with more than one native child.
Co-authored-by: Ayaan Zaidi <hi@obviy.us>