| name | dispatching-parallel-agents |
| description | Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies |
When you have multiple independent problems, dispatch one agent per problem domain and let them work concurrently. Each agent gets isolated context — never your session's history. This preserves your context for coordination.
Use when 2+ independent tasks exist (different test files, subsystems, bugs).
Use when each problem can be understood without context from others.
Use when agents won't interfere (no shared state, no same-file edits).
```dot
digraph when_to_use {
"Multiple failures?" [shape=diamond];
"Independent?" [shape=diamond];
"Can parallelize?" [shape=diamond];
"Single agent" [shape=box];
"Parallel dispatch" [shape=box];
"Sequential agents" [shape=box];
"Multiple failures?" -> "Independent?" [label="yes"];
"Independent?" -> "Single agent" [label="no - related"];
"Independent?" -> "Can parallelize?" [label="yes"];
"Can parallelize?" -> "Parallel dispatch" [label="yes"];
"Can parallelize?" -> "Sequential agents" [label="shared state"];
}
```
**Identify independent domains** — Group failures by what's broken. Each domain is one agent's scope.
**Create focused prompts** — Each agent gets: specific scope (one file/subsystem), clear goal, constraints (don't change other code), expected output format.
**Dispatch in parallel** — Use Task tool for all agents concurrently.
**Review and integrate** — Read each summary, verify fixes don't conflict, run full test suite, integrate changes.
Prompt structure
Good agent prompts are focused, self-contained, and specific about output:
Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
1. "should abort tool with partial output" - expects 'interrupted at'
2. "should handle mixed completed and aborted" - fast tool aborted
3. "should track pendingToolCount" - expects 3 results, gets 0
These are timing/race condition issues. Your task:
1. Read test file, understand what each verifies
2. Identify root cause
3. Fix (don't just increase timeouts)
Return: Summary of root cause and changes made.
Each agent gets narrow, self-contained scope.
Never dispatch without specific error messages and test names.
Always run full test suite after integrating all fixes.
Spot-check agent work — agents can make systematic errors.
"Fix all the tests" — too broad, agent gets lost. Be specific: one file or subsystem per agent.
Dispatching agents for related failures — fix one might fix others. Investigate together first.