Skip to content

< all problems92 · Level 05, Agents

Fix the Supervisor That Dies With One Subagent

medium · debug · Agents

supervise(subtasks, run) hands each subtask to a subagent and collects the results. In production one subagent hit a bad input, and the report came back with the wrong number of results, the failure in the wrong place, and three attempts billed for a task that could never succeed. Fix it.

run(subtask) is the subagent. It returns a result, or raises TransientError (a flaky tool, worth one more try) or something else (a BadTask, a bug: not worth retrying).

  1. Results come back in subtask order, one slot per subtask, None where it failed.
  2. A TransientError is retried once, so at most two attempts. Any other exception is not retried at all.
  3. Every failure is recorded in failed as {"subtask": ..., "error": "ClassName: message"}, in order, with the last error seen.
  4. attempts counts every call to run.
  5. supervise never raises because a subagent did. The rest of the swarm's work still comes back.

Return {"results": [...], "failed": [...], "attempts": n}.

Three things are wrong with the current version. Run the tests and read the shape of what comes back before you change anything: the length of results is the first clue.