Skip to content

improve: count running subagents on the working line - #165477

Merged
shakkernerd merged 2 commits into
mainfrom
subagent-running-count
Oct 6, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
subagent-running-count

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #165378

What Problem This Solves

When an agent starts subagents and keeps working on its own part, the Control UI chat shows only the agent's working line: the claw, a timer and a token count. Nothing in the transcript says that subagents are running. They only show up there if the agent later hands off and waits, and in the common case where the agent works until they are all done, they never appear in the line the reader is watching. The Subagents panel has them, but it is a separate place to look.

User Impact

While an agent is working and has subagents running, its working line now ends with their count: "12s · 431 output tokens · 3 subagents running". The number drops as they finish ("2 subagents running", "1 subagent running") and the words disappear when none are left, leaving the normal working line.

Only subagents are counted. A child session the agent opened in its own right, such as one launched with visible, is a session of its own and is left out, as it is on the wait line.

It is a count only. There are no names, no second timer, and nothing about what each subagent is doing; the Subagents panel remains the place for that. If the agent hands off while some are still running, the line becomes "Waiting on 2 subagents" from #165378, never both at once.

The count appears only once the chat's own list of that session's subagents has loaded, the same rule the wait line follows. The chat does not load that list when Swarm is turned off with tools.swarm: false, so in that configuration no count appears and the working line is unchanged. Sessions without running subagents render exactly as before.

This is the second PR in a stack of four and builds on #165378. Still to come: drawing the answer after a wait in the same block, and showing finished subagents inside the collapsed operations group.

Why This Change Was Made

#165378 taught the wait line to count unfinished subagents from the session rows the pane already holds. This PR uses the same answer one state earlier.

The filter that decides which children are unfinished moves into one function in chat-subagent-wait.ts. The wait resolver and the new countRunningSubagents both call it, so the working line and the wait line cannot disagree about the number at the moment of a handoff, and both wait for the roster's own child query before saying anything.

The working indicator takes the count as an option and appends it after the timer and tokens. It ignores the option when it is drawing a subagent wait, because that line already says who is left. The transcript's render key for live status now includes the count, so a subagent finishing updates the working line and leaves every other row memoized.

Correction from a live run. The shared filter counted every unfinished child session. A real run that opened two child sessions with visible showed them as "2 subagents running". The second commit leaves out children that are dashboard sessions, which is what a visible launch opens, the same test the wait line in #165378 now applies before it names anyone. Every other child, including one on the ACP runtime, is still counted. The number itself also shows sooner than it did: #165378 now has the roster read its child list as soon as the session names a child it does not hold, which in live runs of the stack brought "1 subagent running" up within two tenths of a second of the launch row appearing, instead of up to five seconds later.

The wording is two strings, singular and plural, following the existing token-count label. The chat documentation describes the behavior, including that counts and names depend on the session's subagent list and that the pane does not load it with Swarm turned off.

Evidence

The captures come from the repository's mocked Control UI browser harness, driven by one scripted run on the previous PR in the stack and on this head. An agent in a dashboard session starts three subagents from an exec step and keeps working while they finish one by one; an on-screen cue names each Gateway event. The fourth row is from a second run where the agent hands off with three still running, and shows that the wait line is not given the suffix.

Visual evidence

View Before After
Agent working, three subagents running Reply, a subagent launch row, and a working line showing only the claw and an 11 second timer The same working line ending with 3 subagents running
One subagent left Working line showing only the claw and a timer while one subagent is still running Working line ending with 1 subagent running
All subagents finished, agent still working Working line showing the claw and a timer Working line showing the claw and a timer, identical to before, with no subagent wording
Handoff with three still running Wait line under the reply reading Waiting on 3 subagents The same wait line reading Waiting on 3 subagents, with no running-count suffix added

Same scripted run on the previous PR in the stack (left) and on this head (right)

unit4-alongside-side-by-side.mp4

Visual verification

  • Baseline: subagent-wait-row@c6949cb445befb2e0032bb589bf36ecbaf0594cc (the head of improve: show the subagent wait in place without handoff markers #165378)
  • Exact head: 32f981046fe2d7d73843efb39ea015a14f85ea9d
  • Runtime: Control UI mocked E2E harness (bundled build of the tested checkout), Chromium, dark theme, 1280x800
  • Working line while subagents run: timer only before; timer followed by the running count on this head
  • Count as subagents finish: "3 subagents running", "2 subagents running", "1 subagent running", then no wording
  • Wait line after a handoff: unchanged, "Waiting on 3 subagents" with no suffix
  • Before and after use the same recorder, viewport, theme and fixture; the per-side recordings are kept beside the composed comparison

The mocked run reports no output tokens, so no capture shows the token count and the suffix together. A unit test covers that combination.

Tests

  • chat-subagent-wait.test.ts: the count includes direct children that are running or waiting on their own subagents, leaves out a child session that is not a subagent, includes one on the ACP runtime, and is zero before the roster has loaded, when the session reports no active subagent run, and without a session. The rendered working line carries "3 subagents running" together with the token count, uses the singular for one, shows nothing for zero, and never adds the suffix to a wait line. The order of the two comes from the template; no test or capture pins it.
  • chat-subagent-waiting.e2e.test.ts: in the browser, a working parent's line shows "1 subagent running" once its child starts, does not overflow in the phone layout at 390 px, and after the handoff the wait line carries no suffix element.

Cost on one worker (pnpm test <files> --maxWorkers=1): the five subagent unit files together take 3.6 s wall for 102 tests; after the fix commit chat-subagent-wait.test.ts alone takes 3.6 s for 17. The changed browser test takes 15.2 s alone. In CI on an earlier head of this PR, the browser shard that ran (checks-ui-e2e 1/2) took 161 s and the three unit shards (checks-ui) 295 to 399 s.

Validation

Head 32f981046fe (tree 5ba60e250c7c), stacked on #165378, rebased onto main at c1005a2ee59. The rebase changed no code in this PR's two commits: git range-diff against the previous head (fca74edc5cc) shows only moved diff context. Every row ran on this exact tree, on a 128-core Linux server (Ubuntu 26.04, Node 26.8.2). The rows ran side by side in five separate checkouts of the tree, one per lane, so that no two lanes shared build or cache directories.

Check Result
Static stage, 36 of 37 selected checks (format, lint, boundaries, docs, dead code, import cycles) pass
Static stage, the remaining check, deadcode:unused-files fails on the base commit itself (below)
Line-cap and max-lines ratchets with hosted-runner leniency off pass
Type graphs (core tests, ui, extension tests, scripts, test root) pass
Node test rows, 20 files, 243 passed and 2 skipped pass
Control UI performance check against the base pass
Control UI unit suite on the pinned Bun runtime, 3 shards, 1,639 files, 22,692 passed and 6 skipped pass
Mocked-browser suite, 8 shards, 387 files, 1,788 tests pass

The failing static check is inherited. deadcode:unused-files reports src/infra/open-file-descriptors.test-support.ts. Nothing references that file at c1005a2ee59, the commit this stack is rebased onto, and this stack touches neither it nor anything else under src/infra. main removed the file afterwards in bedc8ae077c. The failure stopped the stage before its last two checks, the architecture check and the additional boundary checks, so I ran those two on their own on the same tree; both pass.

Every test row passed on its first run on this head.

Live runs. On the rebased code, with a real agent in a local preview, "1 subagent running" appeared 0.1 to 0.2 seconds after the first launch row in three runs and reached 3 within 0.7 seconds. It then counted down to 2 and 1 as the subagents finished. In two runs the wording disappeared when the last one finished while the agent was still working; in the third the agent handed off with one still running and the line became the wait line, never both at once. A run that launched two child sessions with visible was seen once, on an earlier candidate, and showed no subagent count on the working line; the preview's Gateway has refused visible launches since, so that case rests on the unit test.

This PR was validated before on a macOS arm64 worker and, before the rebase, on this server against main at dfd37e81d56; those records are in this description's edit history.

chat-transcript-projection.ts is at 690 counted lines against the 700-line cap after this PR, from 686 after #165378. Later PRs in this stack move code out of it rather than add to it.

Known gaps in test coverage: the count dropping through the full transcript in a committed test (shown in the captures, asserted at renderer level), and the suffix beside the approval-wait and startup-label variants of the working line. A child session created mid-run, which the first version of this PR relied on existing roster updates for, is covered in #165378 by the roster test for a child the parent names first.

Hosted CI on this head. The run stops at security-fast: its production dependency audit reports a high-severity advisory published against source-map-js (GHSA-68fv-2mgg-jv7q), and the fail-fast step then cancels the remaining jobs. This stack changes no dependency, main fails the same job on its current commits, and #165902 is open to pin the fixed version. I have not rerun CI.

Restacked after #165378 landed. #165378 was squashed into main, so this branch was replayed onto main at 59fc07dcb58. The head is now 9119f70cf73; git range-diff against the previous head (32f981046fe) shows every commit unchanged. The validation, captures and reviews above were made on that previous head.

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@shakkernerd
shakkernerd added this pull request to stack #165478 October 5, 2026 09:26
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: S labels Oct 5, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 12:49 AM ET / 04:49 UTC (Revision 8).

ClawSweeper review

What this changes

The Control UI appends the number of running subagents to the agent’s working line, sharing child filtering with the wait line and updating English copy, documentation, and tests.

Merge readiness

✅ Ready for maintainer review

Keep open: the working-line count remains a distinct improvement absent from current main. No actionable introduced defect was found, and the author is a repository member.

Likely related people: shakkernerd and steipete, based on merged work on the chat status surface.

Priority: P3
Reviewed head: 9119f70cf735a763409b167b18ccf6b9c12060e2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with useful inspected visual evidence, preserved proof continuity, and no blocking review findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected paired Chromium screenshots directly demonstrate the working-indicator count at three and one using the production UI with a mocked Gateway; the body also reports real-agent countdown and handoff runs. All eight changed blobs match the evidenced earlier head after restacking. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected paired Chromium screenshots directly demonstrate the working-indicator count at three and one using the production UI with a mocked Gateway; the body also reports real-agent countdown and handoff runs. All eight changed blobs match the evidenced earlier head after restacking. No stored-data contract changes.
Evidence reviewed 7 items Verified introduction boundary: Reviewed the pinned merge-base-to-head changes. The patch adds presentation behavior without changing Gateway contracts, dependencies, permissions, or persisted state; the base-only event-loop test is outside this PR’s introduced changes.
Current main still lacks the working count: Current main has the merged roster-backed wait resolver but no running-count resolver or working-line suffix. The merged predecessor #165378 explicitly leaves this working-state improvement to the next PR.
Shared filtering and render invalidation: Both statuses use the same unfinished-child filter and hydration boundary. Dashboard child sessions are excluded from the working count, ACP children remain eligible, and the count enters the memoization signature only for rows carrying live status.
Findings None None.
Security None None.

How this fits together

The Control UI chat consumes Gateway session rows and the pane’s loaded child-session roster. It projects those facts into the transcript’s working and waiting indicators.

flowchart TD
  A[Gateway session rows] --> C[Loaded child roster]
  B[Selected parent session] --> D[Filter unfinished direct children]
  C --> D
  D --> E[Parent working or waiting]
  E --> F[Working line with count]
  E --> G[Wait line with count or name]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +48, Tests +70, Docs +8. Total +126 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 84 36 +48
Tests 2 71 1 +70
Docs 1 15 7 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 170 44 +126

Review metrics

None.

Technical review

Best possible solution:

Keep one roster-backed definition of unfinished children and expose its count in the existing working indicator while preserving the handoff wait presentation.

Do we have a high-confidence way to reproduce the issue?

Not applicable to a bug reproduction: this adds status visibility. Current-main source and inspected before/after screenshots establish the missing working-line count.

Is this the best way to solve the issue?

Yes: reusing the existing roster and wait filter is a focused solution, and the memoization update carries count changes through the transcript without introducing another state owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against eff939dc29c3.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a bounded chat-status visibility improvement with no change to execution, delivery, configuration, or stored state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Inspected paired Chromium screenshots directly demonstrate the working-indicator count at three and one using the production UI with a mocked Gateway; the body also reports real-agent countdown and handoff runs. All eight changed blobs match the evidenced earlier head after restacking. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected paired Chromium screenshots directly demonstrate the working-indicator count at three and one using the production UI with a mocked Gateway; the body also reports real-agent countdown and handoff runs. All eight changed blobs match the evidenced earlier head after restacking. No stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected paired Chromium screenshots directly demonstrate the working-indicator count at three and one using the production UI with a mocked Gateway; the body also reports real-agent countdown and handoff runs. All eight changed blobs match the evidenced earlier head after restacking. No stored-data contract changes.

Evidence

What I checked:

  • Verified introduction boundary: Reviewed the pinned merge-base-to-head changes. The patch adds presentation behavior without changing Gateway contracts, dependencies, permissions, or persisted state; the base-only event-loop test is outside this PR’s introduced changes. (ui/src/pages/chat/chat-subagent-wait.ts:76, 9119f70cf735)
  • Current main still lacks the working count: Current main has the merged roster-backed wait resolver but no running-count resolver or working-line suffix. The merged predecessor improve: show the subagent wait in place without handoff markers #165378 explicitly leaves this working-state improvement to the next PR. (ui/src/pages/chat/chat-subagent-wait.ts:51, eff939dc29c3)
  • Shared filtering and render invalidation: Both statuses use the same unfinished-child filter and hydration boundary. Dashboard child sessions are excluded from the working count, ACP children remain eligible, and the count enters the memoization signature only for rows carrying live status. (ui/src/pages/chat/components/chat-transcript-projection.ts:376, 9119f70cf735)
  • Inspected visual evidence: Inspected all four prepared screenshots: paired baseline/after images directly show the added '3 subagents running' and '1 subagent running' labels beside the existing timer. The captured PR body identifies these as Chromium recordings of the bundled Control UI with a mocked Gateway, and separately reports real-agent countdown and handoff observations. Source snapshot identity: e158a5b31ba7ed03e41dd2e337416f35a843519deb344cac67dc4fd7dc5532d3. (32f981046fe2)
  • Proof continuity after restacking: GitHub’s untruncated earlier-head tree and the local current-head tree have identical blob hashes for all eight introduced files. This preserves the inspected visual proof and previous review’s source identity after restacking. Local inspection of the earlier commit failed because its objects were unavailable; the read-only GitHub tree check resolved that comparison. (32f981046fe2)
  • Focused coverage and validation limits: Read both changed test files completely. Coverage exercises hydration, non-subagent exclusion, singular/plural/zero rendering, token coexistence, handoff suppression, and phone-width layout. The PR reports focused timing and broad validation on the earlier head; no tests were executed during this read-only review. Diff whitespace checking passed and the checkout remains clean. (ui/src/pages/chat/chat-subagent-wait.test.ts:201, 9119f70cf735)

Likely related people:

  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-05T09:30:44.460Z sha 4440709 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T09:40:15.468Z sha 4440709 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T10:03:33.178Z sha 4440709 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T23:01:15.826Z sha fca74ed :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T23:10:10.127Z sha fca74ed :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T02:10:33.659Z sha 32f9810 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T02:51:19.616Z sha 32f9810 :: needs maintainer review before merge. :: none

While a session was still working, its transcript said nothing about the
subagents it had running until it handed off.

The working line now ends with their count, such as "3 subagents running",
and drops the words when none are left. It shares the roster-backed count
with the wait line, so the two agree at a handoff.
A child session opened in its own right, with `visible: true`, was counted
as a running subagent. It is a session of its own, so the working line
leaves it out, as the wait line now does.
@shakkernerd
shakkernerd force-pushed the subagent-running-count branch from 32f9810 to 9119f70 Compare October 6, 2026 04:43
@shakkernerd shakkernerd self-assigned this Oct 6, 2026
@shakkernerd
shakkernerd merged commit 6fe508a into main Oct 6, 2026
90 checks passed
@shakkernerd
shakkernerd deleted the subagent-running-count branch October 6, 2026 04:56
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Improved: while an agent works with subagents running, the Control UI chat's working line now shows how many are still running.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
* improve: count running subagents on the working line

While a session was still working, its transcript said nothing about the
subagents it had running until it handed off.

The working line now ends with their count, such as "3 subagents running",
and drops the words when none are left. It shares the roster-backed count
with the wait line, so the two agree at a handoff.

* fix: count only subagents on the working line

A child session opened in its own right, with `visible: true`, was counted
as a running subagent. It is a session of its own, so the working line
leaves it out, as the wait line now does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant