cmux NEXT subagents: a completed turn ends only the subagents its tool calls started; Codex children run on
Follow-up to #24031, from its review. #24031 makes a completed turn end its still-running foreground subagents, so Leo's Inspector stops counting stale ones as running. But Codex's children run in their own threads and can outlive their turn (the model may end the turn without a wait). After #24031 a live Codex child would read done early.
Change.
- Webview (
subagentFold.ts): a completed turn ends only the subagents a tool call started. That is Claude's Agent call, which its turn waits on. acpmux sends its id astoolCallId, from_meta.claude.toolUseId. Codex's native children (codex-acp 1.10.0 withnativeSubagentSessions, the pinned default) come with no tool call and run on. Cancelled and lost turns are unchanged. - acpmux (
subagents.rscodex_legacy): children from the legacy path (older or user-configured adapters) carrybackground: true. Codex reports their end itself: aninterruptedorcompletedactivity item, or an agent status.
Tests (red first).
- Webview:
subagent-stopped-after-cancel.test.ts"a subagent no tool call of the turn started runs on after the turn completes" was red at 945e13e4. Thespawnedhelper now carries thetoolCallIdacpmux sends for Claude. Subagent, summary, inspector and background-task suites: 107 pass. The 1 failure (summary-background-work.test.tsx) also fails with base sources. - acpmux:
subagents::codex_tests::codex_spawned_agents_are_backgroundwas red at 2f53e11c. All 20subagentlib tests pass.
No capture: no UI change. It only decides which subagents a completed turn ends.
š¤ Generated with Claude Code
Agent session: huge-blue
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Follow-up to #24031: a completed turn now ends only the subagents its tool calls started, so Codex's children, which run in their own threads and can outlive their turn, keep running instead of being read as done. No UI change; this only decides which subagents a completed turn ends.
Changes
- Webview: a completed turn ends only subagents with a
toolCallId; Codex's native children have none and run on. - acpmux: legacy Codex adapters mark their subagents as
background, so a client never ends them at turn end.