tact icon indicating copy to clipboard operation
tact copied to clipboard

[bug] Root Agent Is Not Woken for Subagents That Finish Mid-Turn or Fail

Open patrick-ogrady opened this issue 3 weeks ago • 0 comments

When the root agent ends its turn to wait on subagents, Tact should start a continuation turn once a child finishes. Often it does not: the session sits idle with every child done until I nudge it ("I think it finished?").

The wake is edge-triggered in the TUI. RootNode::apply_subagent_update starts a continuation only when the status update is Completed, belongs to a direct child, and arrives while no root turn is running. Two cases fall through:

  • A child completes while a root turn is running. The update is ignored, and turn_ended only drains the prompt queue, so nothing reports the child once the turn ends. completed_subagent_does_not_start_a_competing_active_turn pins the first half. With several children, each continuation turn is itself a window for the next completion to be lost. In one session with six review seats, wakes fired for two seats, the last seat finished around the second continuation turn, and the root then idled for 18 minutes.
  • A child fails. Only Completed wakes the root. A child that died on a transport error after the root had ended its turn left the root idle for 49 minutes.

#287 fixed the related wait_agent case (#285), but the wake has the same shape of problem: it reads the moment of the update instead of what the root has yet to be told.

Proposal

  • Track, for each direct child, the last terminal outcome the root has been shown, whether through a wait_agent or list_agents result or through a wake prompt. A child whose Completed or Failed outcome differs from it is unreported.
  • When a child finishes while the root is idle, or a root turn completes with nothing queued, start one continuation naming every unreported child.
  • Leave Interrupted children alone, since an interrupt is something the root or the user asked for. Likewise skip the wake at the end of a root turn that failed or was interrupted, and report at the end of the next turn that completes.

Open questions

  • Should the subagent runtime own "outcomes not yet delivered to the parent" instead of the TUI, so a subagent that manages its own children gets the same treatment?

patrick-ogrady avatar Nov 11 '26 22:11 patrick-ogrady