Core Principle
Dispatch one agent per independent problem domain. Let them work concurrently. Parallel investigation of independent failures is orders of magnitude faster than sequential debugging.When to Use
1
Multiple failures?
Do you have 2+ failing test files, broken subsystems, or bugs?
2
Are they independent?
Can each problem be understood without context from the others?
- Yes → Continue to next step
- No (related) → Single agent investigates all
3
Can they work in parallel?
Do they share state that would cause interference?
- Yes (no shared state) → Parallel dispatch
- No (shared state) → Sequential agents
Use When
Don’t Use When
The Pattern
1. Identify Independent Domains
Group failures by what’s broken:2. Create Focused Agent Tasks
Each agent gets:- Specific scope: One test file or subsystem
- Clear goal: Make these tests pass
- Constraints: Don’t change other code
- Expected output: Summary of what you found and fixed
3. Dispatch in Parallel
4. Review and Integrate
When agents return:- Read each summary
- Verify fixes don’t conflict
- Run full test suite
- Integrate all changes
Agent Prompt Structure
Good agent prompts are:- Focused - One clear problem domain
- Self-contained - All context needed to understand the problem
- Specific about output - What should the agent return?
Example Prompt
Common Mistakes
Too Broad
❌ “Fix all the tests” - agent gets lost✅ “Fix agent-tool-abort.test.ts” - focused scope
No Context
❌ “Fix the race condition” - agent doesn’t know where✅ Paste the error messages and test names
No Constraints
❌ Agent might refactor everything✅ “Do NOT change production code” or “Fix tests only”
Vague Output
❌ “Fix it” - you don’t know what changed✅ “Return summary of root cause and changes”
Real Example from Session
Scenario: 6 test failures across 3 files after major refactoring Failures:agent-tool-abort.test.ts: 3 failures (timing issues)batch-completion-behavior.test.ts: 2 failures (tools not executing)tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)
Agent 1 Results
Agent 1 Results
Replaced timeouts with event-based waiting
- Changed
setTimeout(100)towaitForEvent('tool-aborted') - Fixed race condition in abort handler
- All 3 tests now pass
Agent 2 Results
Agent 2 Results
Fixed event structure bug (threadId in wrong place)
- Moved
threadIdfrom nested object to top level - Updated event handler to read correct location
- Both tests now pass
Agent 3 Results
Agent 3 Results
Added wait for async tool execution to complete
- Test was checking results before tools executed
- Added
await waitForCompletion()before assertions - Test now passes
Key Benefits
Parallelization
Multiple investigations happen simultaneously
Focus
Each agent has narrow scope, less context to track
Independence
Agents don’t interfere with each other
Speed
3 problems solved in time of 1
Verification After Agents Return
1
Review each summary
Understand what changed in each domain
2
Check for conflicts
Did agents edit the same code or make conflicting assumptions?
3
Run full suite
Verify all fixes work together:
4
Spot check
Agents can make systematic errors. Verify the logic makes sense.
Decision Tree
Performance Impact
From real debugging session (2025-10-03):Related Skills
- Verification Before Completion - Verify agent work before trusting results
- Requesting Code Review - Review integrated changes after parallel work