关于 dispatching-parallel-agents
为 Agent 提供并行处理独立问题的工作流程指南,包含任务拆分、范围约束、并发派发及结果审查与整合步骤。适用于将彼此无依赖的测试或子系统问题分配给多个 Agent。
主要功能
- 01识别可独立处理的问题
- 02编写范围明确的 Agent 任务
- 03并发派发并跟踪进度
- 04审查结果并整合变更
适用场景
- 01将多个独立测试失败分派给 Agent
- 02避免并行修改同一文件引发冲突
- 03汇总修复并运行完整测试套件
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ izyanrajwani/ agent-skills-library --skill dispatching-parallel-agents安装后在 Claude Code 中输入/dispatching-parallel-agents确认已加载。
详细介绍
并行调度 Agent
为每个独立问题调度一个 Agent,让它们并行工作。
调度工作流
复制并跟踪:
- [ ] 1. Identify independent domains
- [ ] 2. Create focused agent tasks
- [ ] 3. Dispatch in parallel
- [ ] 4. Review and integrate
1. 识别独立领域
按问题所在位置对失败进行分组:
- 文件 A 测试:工具审批流程
- 文件 B 测试:批次完成
- 文件 C 测试:中止功能
每个领域彼此独立——修复工具审批不会影响中止测试。
关键检查: 如果修复一个问题可能同时修复其他问题 → 先一起调查(不要并行处理)。
2. 创建明确的 Agent 任务
每个 Agent 都需要:
- 范围: 一个测试文件或子系统
- 目标: 让这些测试通过
- 限制: 不要更改无关代码
- 输出: 问题发现和修复的摘要
3. 并行调度
示例(Claude Code):
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. 审查并集成
- 阅读每个 Agent 的摘要
- 检查是否存在冲突(是否编辑了相同文件?)
- 如果两个 Agent 修改了同一个文件 → 停止并重新划分范围(每个文件只指定一个负责人)
- 运行完整测试套件
- 如果有失败:
- 检查是否存在合并冲突 → 手动解决
- 如果没有冲突 → 将其作为新失败进行调查
- 重复上述步骤,直到全部通过
Agent 提示词模板
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.
常见错误
| ❌ 错误做法 | ✅ 正确做法 |
|---|---|
| “修复所有测试” | “修复 agent-tool-abort.test.ts” |
| “修复竞态条件” | 粘贴错误消息和测试名称 |
| 不设限制 | “请勿更改生产代码” |
| “修复它” | “返回根本原因和更改内容的摘要” |
示例
场景: 重大重构后,3 个文件中有 6 个测试失败。
失败:
- agent-tool-abort.test.ts:3 个失败(时序问题)
- batch-completion-behavior.test.ts:2 个失败(工具未执行)
- tool-approval-race-conditions.test.ts:1 个失败(执行次数 = 0)
决策: 这些领域彼此独立——中止逻辑、批次完成和竞态条件互不相关。
调度:
Agent 1 → Fix agent-tool-abort.test.ts
Agent 2 → Fix batch-completion-behavior.test.ts
Agent 3 → Fix tool-approval-race-conditions.test.ts
结果:
- Agent 1:将超时替换为基于事件的等待
- Agent 2:修复事件结构错误(threadId 位于错误位置)
- Agent 3:添加对异步工具执行的等待
集成: 所有修复彼此独立,没有冲突,完整测试套件全部通过。
评论
支持 Markdown