Skip to content

cmux NEXT subagents: a completed turn ends its foreground subagents, so Running counts only live ones - #24031

Merged
teamleaderleo merged 2 commits into
feat-cmux-nextfrom
cmux/subagent-ends-with-turn
Oct 22, 2026
Merged

teamleaderleo merged 2 commits into
feat-cmux-nextfrom
cmux/subagent-ends-with-turn

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Leo's Inspector read "5 running · 3 failed · 89 done" while about 3 subagents were live (his screenshot from the "THIS BECAME A SIDEBAR FOR NO REASON" report; the panel itself is fixed in #24020).

Cause. The counts, the avatars and the rows all come from one source and agree. What was wrong is a foreground subagent whose end the harness never sent: it read running for good. subagentsLeft (subagents/subagentFold.ts) ended a turn's subagents only when the turn was cancelled or lost (outcome_unknown), never when it completed normally.

Fix. A turn_result with status: "completed" ends that turn's still-running foreground subagents as completed, so they count as done. A completed turn waited on them: Claude's foreground Agent call returns before the turn can end. Two cases are unchanged:

  • Background subagents run on. acpmux flags them background: true for run_in_background, workflows, and ones moved to the background (claude_stdio/inbound.rs).
  • A subagent that reports again reads running again.

Tests (red first). test/subagent-stopped-after-cancel.test.ts:

  • New: a foreground subagent whose turn completed reads completed, and a background one from the same turn still reads running. Red at d17b3ae.
  • Four existing cases used a foreground spawn to stand in for background work. They now spawn with the background flag, which is what acpmux sends.
  • The subagent, summary, inspector and background-task suites: 106 pass. The 1 failure, in summary-background-work.test.tsx ("the card lists running commands…"), fails the same way with base sources.

No capture: the Subagents count changes only for a subagent left running after its turn completed, and the tests above pin that.

🤖 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

Fixes the subagent Running count so a completed turn ends its foreground subagents, which the harness never reported as done.

  • A turn_result with status: "completed" now ends that turn's still-running foreground subagents as completed, so they no longer read running forever.
  • Background subagents still read running after a completed turn; their behavior is unchanged.
  • Updates tests that used foreground spawns as stand-ins for background work to use the background flag.

Written for commit ec3dac6. Summary will update on new commits.

View guided diff Turn on auto-fix

teamleaderleo and others added 2 commits October 22, 2026 01:45
…so Running counts only live ones

Leo's Inspector read "5 running" with about 3 live: a foreground subagent whose end the
harness never sent read running for good once its turn completed. A completed turn waited
on its foreground subagents, so they read done; background ones run on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bd2-60d2-70e1-8179-d3aa717c8828&host=huge-blue
@teamleaderleo teamleaderleo added the risk:low Risk tier (docs/ci/risk-tiers.md) label Oct 22, 2026
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by summary-panel on huge-blue · session

@blacksmith-sh

blacksmith-sh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Found 13 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmpfc0_3g_a/summary-missing.json (live):/summary-missing.json (live): View Logs
/tmp/tmpgxc478vr/summary-fail.json (live):/summary-fail.json (live): View Logs
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows/
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows
View Logs
[new_workspaces] the window draws no frames/[new_workspaces] the window draws no frames View Logs
[tabs] debug.tab_switch timed 0 of 40 switches/
[tabs] debug.tab_switch timed 0 of 40 switches
View Logs
[tabs] the window draws no frames/[tabs] the window draws no frames View Logs
convention violations found (ERROR lines above)./
convention violations found (ERROR lines above).
View Logs
nightly cmux-tui resolve/nightly cmux-tui resolve View Logs
test_every_submodule_free_checkout_on_an_owned_runner_resets_submodules (main.Reuse
dWorkspaceSubmodules.test_every_submodule_free_checkout_on_an_owned_runner_resets_submo
dules)/
test_every_submodule_free_checkout_on_an_owned_runner_resets_submodules (main.Reuse
dWorkspaceSubmodules.test_every_submodule_free_checkout_on_an_owned_runner_resets_submo
dules)
View Logs
test_every_submodule_free_checkout_on_an_owned_runner_resets_submodules (main.Reuse
dWorkspaceSubmodules.test_every_submodule_free_checkout_on_an_owned_runner_resets_submo
dules) (job='web-bundles')/
test_every_submodule_free_checkout_on_an_owned_runner_resets_submodules (main.Reuse
dWorkspaceSubmodules.test_every_submodule_free_checkout_on_an_owned_runner_resets_submo
dules) (job='web-bundles')
View Logs

...and 3 more test failures. View all on Blacksmith

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@github-actions github-actions Bot added risk:normal Risk tier (docs/ci/risk-tiers.md) and removed risk:low Risk tier (docs/ci/risk-tiers.md) labels Oct 22, 2026
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (subagent, correctness first): SHIP at ec3dac6

  • The reviewer traced claude_stdio and the hub. A sync Agent call's end, its move to the background and its background flag all land before the turn's turn_result (drain_inbound runs before turn_end). Live and reload read the same. A late end event still overwrites completed. 164 subagent tests pass.
  • Caveat for a follow-up: Codex spawnAgent subagents (codex_legacy in acpmux subagents.rs) are never flagged background, so one the model leaves running past its turn would read done early. The follow-up flags them in acpmux.
  • Fleet cmux-ci compile-check --app passed at ec3dac6 (job dd3f93d21637dffcba607f46).
  • Reds not from this diff (subagentFold.ts, direct.ts comment, one test file):

@teamleaderleo
teamleaderleo merged commit 8af11de into feat-cmux-next Oct 22, 2026
@teamleaderleo
teamleaderleo deleted the cmux/subagent-ends-with-turn branch October 22, 2026 01:56
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

high-signal review link / link is red on 10 of 15 fresh feat-cmux-next PR heads in the last 2:00:00, so it is most likely a base red, not this PR's. The base-reds lane has it; a base merge picks up the fix once it lands.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Probably yours: agent-pane-subagents-tab.test.ts, agent-pane-subagents-tab.test.ts, agent-pane-subagents-tab.test.ts and 1 more fails here but not on main's latest full suite. Seen on other PRs too (likely flaky): agent-pane-peer-chat.test.ts. This PR merged before its CI finished: fix forward on main.

CI failed on ec3dac625e (run 39708041632 attempt 1): 1 code, 1 unknown.

Job Verdict Why
web / react-apps-check (3) code a web test failed
web / react-apps-check unknown no known signature; failed step: Check webview test shards

Failures:

  • seen on other PRs agent-pane-peer-chat.test.ts a chat on an SSH machine > counts its running turn from the prompt and offers no machine switch mid-...: failed (job)
  • new in this PR agent-pane-subagents-tab.test.ts the Subagents title opens a tab of active and done subagents, and its rows open them: failed (job)
  • new in this PR agent-pane-subagents-tab.test.ts the Summary tab goes back without closing the Subagents tab: failed (job)
  • new in this PR agent-pane-subagents-tab.test.ts a running subagent in the tab has the transcript row's stop button: failed (job)
  • new in this PR agent-pane-subagents-tab.test.ts the model router's chat, Claude Code named 'cmux', has stop button on a running subagent: failed (job)
Matched log lines
web / react-apps-check (3): (fail) a chat on an SSH machine > counts its running turn from the prompt and offers no machine switch mid-chat [1567.52ms]

Not re-run automatically: web / react-apps-check (3), web / react-apps-check are not machine failures.

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); signatures are its SIGNATURES table. A machine verdict is the runner's fault, not this PR's; yours means the failing file is one this PR changes, also red on main that main's latest full suite fails the same way, seen on other PRs that it failed on another pull request's run lately.

red: cmux-next checks (god files, concurrency, crash safety, l10n); no finished base run on 4ae5de4 to compare; do not merge until green; see lane-rules
red: web / Web status; NEW: green on the base 4ae5de4; do not merge until green; see lane-rules
red: web / react-apps-check; no finished base run on 4ae5de4 to compare; do not merge until green; see lane-rules
red: web / react-apps-check (3); no finished base run on 4ae5de4 to compare; do not merge until green; see lane-rules

Tour of ec3dac625e (run): no media. The tour did not run: only webview code changed (3 path(s)), which the gallery advisory run checks in Linux Chromium on the pull request (its artifact holds any captures); add the media-tour-mac label, then re-add media-tour, to tour it on a Mac.

Gallery before/after for ec3dac6: 16 states rendered, 4 images differ, 1514 more touched states not rendered. Images are in the run's artifact, not on this public PR.

gh run download 39708041531 -R manaflow-ai/cmux -n gallery-advisory-24031-ec3dac625e7b822381ee6c586a76b88d81aab62c (then read gallery-review.json)

States
State Theme Status Diff Picked by
agent-pane.chat-inspector/full Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/full Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/context-connectors-open Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/context-connectors-open Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/changes-breakdown Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/changes-breakdown Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/changes-all Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/changes-all Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/row-hover Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/row-hover Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/subagents-open Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/subagents-open Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/tasks-finished Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/tasks-finished Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/cloud-empty Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-inspector/cloud-empty Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.chat-width/standard Apple System Colors Light unchanged 0% imports direct.ts (1 hops)
agent-pane.chat-width/standard Apple System Colors unchanged 0% imports direct.ts (1 hops)
agent-pane.chat-width/wide Apple System Colors Light unchanged 0% imports direct.ts (1 hops)
agent-pane.chat-width/wide Apple System Colors unchanged 0% imports direct.ts (1 hops)
agent-pane.chat-width/wide-blocks Apple System Colors Light unchanged 0% imports direct.ts (1 hops)
agent-pane.chat-width/wide-blocks Apple System Colors unchanged 0% imports direct.ts (1 hops)
agent-pane.composer-floats/scrolled-to-end Apple System Colors Light unchanged 0% imports direct.ts (1 hops)
agent-pane.composer-floats/scrolled-to-end Apple System Colors unchanged 0% imports direct.ts (1 hops)
agent-pane.composer-floats/composer-grown Apple System Colors Light unchanged 0% imports direct.ts (1 hops)
agent-pane.composer-floats/composer-grown Apple System Colors unchanged 0% imports direct.ts (1 hops)
agent-pane.composer-turn-cycle/idle Apple System Colors Light unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.composer-turn-cycle/idle Apple System Colors unchanged 0% imports subagentFold.ts (1 hops)
agent-pane.composer-turn-cycle/running Apple System Colors Light changed 0.0437% imports subagentFold.ts (1 hops)
agent-pane.composer-turn-cycle/running Apple System Colors changed 0.0267% imports subagentFold.ts (1 hops)
agent-pane.composer-turn-cycle/subagents-one Apple System Colors Light changed 0.0112% imports subagentFold.ts (1 hops)
agent-pane.composer-turn-cycle/subagents-one Apple System Colors changed 0.0065% imports subagentFold.ts (1 hops)

Pick other states with a Gallery: entry.id, entry.id/variant line in the PR body.

teamleaderleo added a commit that referenced this pull request Oct 22, 2026
…l calls started

Codex's native children (codex-acp nativeSubagentSessions) come with no tool call and no
background flag, and run on in their own threads: #24031 would have read them done when the
turn completed. Only a subagent a tool call started (Claude's Agent call, which its turn
waits on) ends with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bd2-60d2-70e1-8179-d3aa717c8828&host=huge-blue
teamleaderleo added a commit that referenced this pull request Oct 22, 2026
…l calls started; Codex children run on (#24087)

* test(acpmux): Codex spawnAgent subagents are background work (red)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bd2-60d2-70e1-8179-d3aa717c8828&host=huge-blue

* acpmux: every Codex spawnAgent subagent is background work, so a completed turn never ends it

Codex runs each child in its own thread; the model may end its turn without a wait.
Follow-up to #24031's review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bd2-60d2-70e1-8179-d3aa717c8828&host=huge-blue

* test(cmux-next): a subagent no tool call started runs on after its turn completes (red)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bd2-60d2-70e1-8179-d3aa717c8828&host=huge-blue

* cmux NEXT subagents: a completed turn ends only the subagents its tool calls started

Codex's native children (codex-acp nativeSubagentSessions) come with no tool call and no
background flag, and run on in their own threads: #24031 would have read them done when the
turn completed. Only a subagent a tool call started (Claude's Agent call, which its turn
waits on) ends with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?harness=claude&session=01a15bd2-60d2-70e1-8179-d3aa717c8828&host=huge-blue

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant