dispatching-parallel-agents
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDispatching Parallel Agents
调度并行Agent
Dispatch one agent per independent problem. Let them work concurrently.
为每个独立问题分配一个Agent,让它们并行工作。
Dispatch Workflow
调度工作流
Copy and track:
- [ ] 1. Identify independent domains
- [ ] 2. Create focused agent tasks
- [ ] 3. Dispatch in parallel
- [ ] 4. Review and integrate复制并跟踪:
- [ ] 1. 识别独立领域
- [ ] 2. 创建聚焦的Agent任务
- [ ] 3. 并行调度
- [ ] 4. 审核与集成1. Identify Independent Domains
1. 识别独立领域
Group failures by what's broken:
- File A tests: Tool approval flow
- File B tests: Batch completion
- File C tests: Abort functionality
Each domain is independent—fixing tool approval doesn't affect abort tests.
Critical check: If fixing one might fix others → investigate together first (don't parallelize).
按故障类型分组:
- 文件A测试:工具审批流程
- 文件B测试:批处理完成逻辑
- 文件C测试:终止功能
每个领域相互独立——修复工具审批流程不会影响终止测试的结果。
关键检查: 如果修复一个问题可能解决其他问题→先一起调查(不要并行处理)。
2. Create Focused Agent Tasks
2. 创建聚焦的Agent任务
Each agent needs:
- Scope: One test file or subsystem
- Goal: Make these tests pass
- Constraints: Don't change unrelated code
- Output: Summary of findings and fixes
每个Agent需要明确:
- 范围: 单个测试文件或子系统
- 目标: 使这些测试通过
- 约束: 不得修改无关代码
- 输出: 调查结果与修复方案总结
3. Dispatch in Parallel
3. 并行调度
Example (Claude Code):
typescript
Task("Fix agent-tool-abort.test.ts failures")
Task("Fix batch-completion-behavior.test.ts failures")
Task("Fix tool-approval-race-conditions.test.ts failures")示例(Claude Code):
typescript
Task("Fix agent-tool-abort.test.ts failures")
Task("Fix batch-completion-behavior.test.ts failures")
Task("Fix tool-approval-race-conditions.test.ts failures")4. Review and Integrate
4. 审核与集成
- Read each agent's summary
- Check for conflicts (same files edited?)
- If two agents touched the same file → stop and re-scope (one owner per file)
- Run full test suite
- If failures:
- Check for merge conflicts → resolve manually
- If no conflicts → investigate as new failures
- Repeat until green
- 阅读每个Agent的总结报告
- 检查是否存在冲突(是否修改了同一文件?)
- 如果两个Agent修改了同一文件→立即停止并重新划分范围(每个文件仅分配一个负责人)
- 运行完整测试套件
- 若仍有失败:
- 检查是否存在合并冲突→手动解决
- 若无冲突→将其视为新故障进行调查
- 重复上述步骤直至所有测试通过
Agent Prompt Template
Agent提示词模板
markdown
Fix the [N] failing tests in [file path]:
1. "[test name]" - [error summary]
2. "[test name]" - [error summary]
Context: [relevant background, e.g., "These are timing/race condition issues"]
Your task:
1. Read the test file, understand what each test verifies
2. Identify root cause—timing issues or actual bugs?
3. Fix by [preferred approach, e.g., "replacing arbitrary timeouts with event-based waiting"]
Do NOT: [anti-patterns, e.g., "just increase timeouts—find the real issue"]
Return: Summary of root cause and changes made.markdown
修复[文件路径]中的[N]个失败测试:
1. "[测试名称]" - [错误摘要]
2. "[测试名称]" - [错误摘要]
上下文:[相关背景信息,例如:"这些是时序/竞态条件问题"]
你的任务:
1. 阅读测试文件,理解每个测试的验证内容
2. 确定根本原因——是时序问题还是实际Bug?
3. 通过[首选方案,例如:"将任意超时替换为基于事件的等待"]进行修复
禁止:[反模式,例如:"不要只是增加超时时间——找到真正的问题"]
返回:根本原因总结及所做的修改。Common Mistakes
常见错误
| ❌ Bad | ✅ Good |
|---|---|
| "Fix all the tests" | "Fix agent-tool-abort.test.ts" |
| "Fix the race condition" | Paste error messages + test names |
| No constraints | "Do NOT change production code" |
| "Fix it" | "Return summary of root cause and changes" |
| ❌ 错误做法 | ✅ 正确做法 |
|---|---|
| "修复所有测试" | "修复agent-tool-abort.test.ts" |
| "修复竞态条件" | 粘贴错误信息 + 测试名称 |
| 无约束条件 | "禁止修改生产代码" |
| "修复它" | "返回根本原因总结及修改内容" |
Example
示例
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)
Decision: Independent domains—abort logic separate from batch completion separate from race conditions.
Dispatch:
Agent 1 → Fix agent-tool-abort.test.ts
Agent 2 → Fix batch-completion-behavior.test.ts
Agent 3 → Fix tool-approval-race-conditions.test.tsResults:
- Agent 1: Replaced timeouts with event-based waiting
- Agent 2: Fixed event structure bug (threadId in wrong place)
- Agent 3: Added wait for async tool execution
Integration: All fixes independent, no conflicts, full suite green.
场景: 重大重构后,3个文件中出现6个测试失败。
故障详情:
- agent-tool-abort.test.ts:3个失败(时序问题)
- batch-completion-behavior.test.ts:2个失败(工具未执行)
- tool-approval-race-conditions.test.ts:1个失败(执行次数=0)
决策: 所有领域相互独立——终止逻辑、批处理完成逻辑与竞态条件逻辑互不影响。
调度方案:
Agent 1 → 修复agent-tool-abort.test.ts
Agent 2 → 修复batch-completion-behavior.test.ts
Agent 3 → 修复tool-approval-race-conditions.test.ts结果:
- Agent 1:将超时替换为基于事件的等待机制
- Agent 2:修复了事件结构Bug(threadId位置错误)
- Agent 3:添加了异步工具执行的等待逻辑
集成结果: 所有修复相互独立,无冲突,完整测试套件全部通过。