[FEATURE] Expose queued/pending Workflow subagents to SDK / headless clients (only visible via in-process /workflows)
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When the Workflow tool spawns N subagents (e.g. via parallel()/pipeline()), the runtime runs up to ~availableParallelism of them concurrently and queues the rest. On a small host (e.g. 2 vCPUs) only ~2 run at a time and the other N−2 wait.
A headless / SDK client (a custom UI built on @anthropic-ai/claude-agent-sdk) has no way to observe the queued, not-yet-started subagents. It can only see a worker once it has started. So a workflow the model describes as "spawning 10 subagents" renders in a custom UI as just the ~2 that currently fit the concurrency cap — the queued 8 are invisible until they begin.
The interactive /workflows command shows the full roster (running and queued) — but only because it runs in-process and reads the workflow engine's live in-memory roster directly. That roster is never exposed to an out-of-process SDK consumer.
What I verified (TypeScript SDK)
With a 15-subagent workflow and a ~68s queued window (sampled on disk every 0.5s), queued workers are absent from every client-accessible surface:
task_startedfires only for the workflow itself (task_type: "local_workflow") and each running worker's internallocal_bash— never for a queued worker.SubagentStart/SubagentStophooks fire only when a worker starts.background_tasks(onStopHookInput/SubagentStopHookInput) contains a single{ type: "workflow" }entry — never the individual workers, running or queued.- The
QueryAPI hasstopTask/backgroundTasks/supportedCommandsbut nolistTasks()/getWorkflowState(). - On disk: the run-state summary (
wf_*.json) is written at completion; the livejournal.jsonlrecords onlystarted/resultevents — no queued entries. - The CLI subprocess's stderr does not carry the roster either.
So the queued roster lives only in the engine's memory and is reachable only by the in-process /workflows TUI.
Proposed Solution
Expose a workflow's queued/pending workers to SDK/headless clients via any one of:
- Include individual workflow workers in
background_taskswithstatus(pending|running), a stableid, and ideally theagent()label/prompt. - Emit
task_startedfor each worker at enqueue time with an initialpendingstatus (thentask_updated→running), so clients can render queued rows that transition to running. - A control request /
Querymethod to list a workflow's planned + pending workers (id,label,status).
Use Case Example
- A custom chat UI is built on the Agent SDK; the agent uses the Workflow tool to run 10 subagents in parallel.
- On a 2-vCPU host, 2 run and 8 queue.
- The assistant says "I've spawned 10 subagents," but the UI can only render the 2 started ones — it looks like only 2 exist.
- With any of the above, the UI could show all 10 (2 running + 8 queued), matching what the in-process
/workflowsview already shows.
Related
- #27916 — "Display active subagent count in the CLI status line" (same visibility need, TUI side).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗