Repository navigation
Description
Motivation
Orchestration runs leave their children behind. A parent agent spawns workers with orchestration_create_agent; when the workers finish they sit in Dispatch as idle rows until the parent calls orchestration_close_run, which often never happens (the parent moved on, was closed, or the user wanted to read the output first). The only cleanup tools today are closing rows one at a time, or Close Old Agents, which is driven by an inactivity threshold and cannot tell an orchestration worker from an agent the user opened by hand.
Intended behavior
A palette command, Close Idle Orchestration Agents:
- Targets every orchestration child in this window: a session with
orchestrationParentId(any agent provider, grandchildren included) that is placed in a project, as a grid pane or a Dispatch row. Buried sessions are out of scope, as for every other close path. - Idle means the child has finished at least one turn and is doing nothing now: its renderer-derived orchestration lifecycle is
completed(the stateorchestration_list_agentsreports), it has started (Dispatch no longer showsstarting), and no history bootstrap is in progress. Working, starting, never-prompted, exited and failed children are left alone. - Coordinators (children that spawned children of their own) are eligible only when every one of their own orchestration children is also being closed, so a coordinator is never closed out from under a working worker.
- Always confirms, listing exactly the agents that will close, through the existing close confirmation dialog. When nothing is idle, a toast says so and nothing opens.
- Closes safely through the same approved-close path Close Old Agents uses: each kill re-checks eligibility against live state (an agent that starts working while the dialog is open is skipped, not killed), children close before their coordinator, one failed kill does not stop the rest, and the result toast reports closed / skipped / kept / failed. No Undo Close entries are pushed, matching
close_runand Close Old Agents, so a purge does not evict the user's own close history.
Acceptance criteria
- The command is registered with a stable title and
surface: 'app', and is offered when the workspace has orchestration children. - Only idle orchestration children are listed and closed; ordinary agents, terminals, linked agents, and working, starting, exited or failed children are untouched.
- A child that becomes busy between confirmation and its kill is skipped.
- A coordinator with a child that is not being closed is not closed.
- Declining the dialog closes nothing.
- Close Old Agents and the new command share one bulk-close loop instead of two copies of the safety logic.
- Regression tests cover the eligibility rule and the close flow; the command catalog snapshot is updated.
Known limitation
A child whose orchestration metadata was stripped by reload, provider switch, resume or rewind (#879) no longer looks like an orchestration child, so this command will not see it until #879 is fixed.
Activity
docs(orchestration): link the Close Idle Orchestration Agents plan to…