[ PROMPT_NODE_22280 ]
dispatching-parallel-agents
[ SKILL_DOCUMENTATION ]
# 分发并行智能体
## 概述
当你遇到多个不相关的故障(不同的测试文件、不同的子系统、不同的 Bug)时,顺序调查会浪费时间。每个调查都是独立的,可以并行进行。
**核心原则:** 为每个独立的问题领域分发一个智能体。让他们并发工作。
## 何时使用
dot
digraph when_to_use {
"Multiple failures?" [shape=diamond];
"Are they independent?" [shape=diamond];
"Single agent investigates all" [shape=box];
"One agent per problem domain" [shape=box];
"Can they work in parallel?" [shape=diamond];
"Sequential agents" [shape=box];
"Parallel dispatch" [shape=box];
"Multiple failures?" -> "Are they independent?" [label="yes"];
"Are they independent?" -> "Single agent investigates all" [label="no - related"];
"Are they independent?" -> "Can they work in parallel?" [label="yes"];
"Can they work in parallel?" -> "Parallel dispatch" [label="yes"];
"Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];
}
**在以下情况使用:**
- 3 个以上测试文件失败,且根本原因不同
- 多个子系统独立损坏
- 每个问题都可以在不需要其他上下文的情况下被理解
- 调查之间没有共享状态
**不要在以下情况使用:**
- 故障是相关的(修复一个可能会修复其他)
- 需要了解完整的系统状态
- 智能体会相互干扰
## 模式
### 1. 识别独立领域
按损坏内容对故障进行分组:
- 文件 A 测试:工具审批流程
- 文件 B 测试:批处理完成行为
- 文件 C 测试:中止功能
每个领域都是独立的——修复工具审批不会影响中止测试。
### 2. 创建专注的智能体任务
每个智能体获得:
- **特定范围:** 一个测试文件或子系统
- **明确目标:** 使这些测试通过
- **约束:** 不要更改其他代码
- **预期输出:** 你发现和修复的内容摘要
### 3. 并行分发
typescript
// 在 Claude Code / AI 环境中
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. 审查与集成
当智能体返回时:
- 阅读每个摘要
- 验证修复内容是否冲突
- 运行完整测试套件
- 集成所有更改
## 智能体提示词结构
好的智能体提示词应该是:
1. **专注的** - 一个明确的问题领域
2