Parent turn completes while newly spawned child agent is still pendingInit
What issue are you seeing?
A parent Codex turn can emit a final assistant message and turn/completed while a child created by spawnAgent is still non-terminal. In the observed trace, the child was still pendingInit when the spawn tool item completed. The parent then finished about six seconds later without calling wait_agent. The child subsequently continued doing work independently after the parent turn was terminal.
Sanitized event sequence:
T+0.000s item/completed
item.type = collabAgentToolCall
item.tool = spawnAgent
item.status = completed
item.agents_states[child].status = pendingInit
T+6.334s assistant/completed
message says the remaining work has been delegated
T+6.791s turn/completed
status = completed
T+~54s child-owned downstream activity begins
and continues for roughly 29 minutes
There was no wait_agent call between spawnAgent and the parent final response.
The important distinction is that item.status=completed only means the spawn tool call completed. The nested child status was still pendingInit. Nevertheless, the runtime accepted the parent final response as a terminal turn boundary.
This creates an implicit detach even though no detach/background operation was requested. The parent no longer collects the child result, and integrations that correctly treat turn/completed as terminal stop observing the parent while child work continues.
What steps can reproduce the bug?
- Enable multi-agent support in a Codex App Server session.
- Ask the main agent to complete a multi-step task and return only after all work is finished.
- Have the main agent call
spawn_agent/spawnAgentwith a long-running child assignment. - Allow the model to emit its final response immediately after the spawn tool call returns, without calling
wait_agent. - Observe the App Server event stream.
The parent can emit assistant/completed followed by turn/completed while the child state in the immediately preceding collabAgentToolCall is pendingInit or running. The child thread can then continue independently.
This was observed through the App Server event protocol on macOS on 2026-07-30. Identifiers and application-specific task details have been removed.
What is the expected behavior?
By default, child agents should participate in structured concurrency:
- A parent turn that spawned a child should not complete while that child is
pendingInitorrunning. - The parent should wait for, cancel, or otherwise resolve every owned child before
turn/completed. - If background execution is intended, it should require an explicit detach/background operation.
- Detached child status and content should remain observable, and terminal child events should be durably delivered to or wake the owning parent/orchestrator.
A useful invariant would be:
parent turn may complete
only if every owned child is terminal
or every remaining child was explicitly detached
Additional information
This appears related to, but distinct from:
- #15723, where background subagents do not wake the calling agent on completion.
- #27352, where a turn completes after a progress/commentary message even though follow-up work remains.
- #19197, which covers orphaned subagent lifecycle and state reconciliation.
This report adds a concrete App Server trace showing turn/completed immediately after spawnAgent, while the child was explicitly reported as pendingInit. The issue is not an SSE disconnect: the upstream App Server itself emitted the terminal parent event, and child-owned side effects continued afterward.
If background children are an intentional supported mode, the protocol still needs an explicit ownership/detach signal and a durable child lifecycle/content stream so clients can distinguish parent turn completed from agent tree completed.
1 Comment
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action