cmux NEXT subagents: a completed turn ends only the subagents its tool calls started; Codex children run on

Merged
TE
15d ago
+70-2

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 as toolCallId, from _meta.claude.toolUseId. Codex's native children (codex-acp 1.10.0 with nativeSubagentSessions, the pinned default) come with no tool call and run on. Cancelled and lost turns are unchanged.
  • acpmux (subagents.rs codex_legacy): children from the legacy path (older or user-configured adapters) carry background: true. Codex reports their end itself: an interrupted or completed activity 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. The spawned helper now carries the toolCallId acpmux 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_background was red at 2f53e11c. All 20 subagent lib 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 Autofix with [code]smith
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.