A Triage Team: Coordinator and Three Specialists
Why This Matters
A specialist with a narrow job and a small context does that job better than a generalist juggling everything. The coordinator’s job is not to do the work; it is to plan it, hand it out, and put the results together.
The team
| Agent | Job | Tools |
|---|---|---|
| Coordinator | Group failures, assign them, assemble the report | None that touch external systems (tools: []); it starts subagents |
| Flaky analyst | Is this intermittent? Uses history and timing | get_test_history, read_log |
| Root-cause investigator | What changed and why did it break? | read_log, get_commit_diff |
| Bug writer | Draft a bug report for a confirmed product bug | search_issues, create_issue (proposal only) |
Defining subagents with the Agent SDK
Subagents are defined in the agents option, each with a description (used to decide when to call it), its own prompt and its own tools. The coordinator starts them through the SDK’s Agent tool, which needs no approval. Two traps: allowedTools only pre-approves, so it does not take built-in tools away from the coordinator (use tools: [] for that), and a subagent’s tools list does not pre-approve those tools either, so list its MCP tools in allowedTools too.
options: {
tools: [], // no built-in tools for the coordinator
permissionMode: "dontAsk",
allowedTools: ["mcp__testpilot__get_test_history", "mcp__testpilot__read_log", "mcp__testpilot__get_commit_diff", "mcp__testpilot__search_issues"],
agents: {
"flaky-analyst": {
description: "Decides whether one failing test is intermittent, using its history and timing. Use for failures with a mixed history or timing errors.",
prompt: FLAKY_ANALYST_PROMPT,
tools: ["mcp__testpilot__get_test_history", "mcp__testpilot__read_log"],
},
"root-cause-investigator": {
description: "Finds what change broke a test, using the log and the commit diff. Use for failures with a stable history that start failing after a commit.",
prompt: ROOT_CAUSE_PROMPT,
tools: ["mcp__testpilot__read_log", "mcp__testpilot__get_commit_diff"],
},
"bug-writer": {
description: "Drafts a bug report for a failure already confirmed as a product bug. Never use for unconfirmed failures.",
prompt: BUG_WRITER_PROMPT,
tools: ["mcp__testpilot__search_issues", "mcp__testpilot__create_issue"],
},
},
}
What the coordinator owns
- The plan: which failure goes to which specialist, and in which order
- Parallelism: independent investigations can run at the same time
- The order of dependent steps: the bug writer only after a confirmed product bug
- The final report: built from the specialists’ structured results, not from their chat
A rule that belongs in code
“Only start the bug writer after a confirmed product bug” is the kind of rule a coordinator will follow most of the time. In TestPilot, the coordinator can only request a bug report; your code checks that a validated product_bug result exists for that failure before the bug writer actually runs. Lesson 54 builds that gate properly.
Exercise
Define the three specialists, run the team on run-1042 and draw the path: which agent handled which failure, and what came back.
Compare with solution/lesson-40-triage-team, which covers lessons 34–40 (see docs/exercises.md, module 5).