关于 distributed-task-execution
一项面向编码 Agent 工作方式的技能,指导将互不相关的故障分配给多个 Agent 并行调查。它强调任务范围明确、彼此独立,并在完成后检查冲突和运行完整测试。
主要功能
- 01按独立问题域拆分故障
- 02为 Agent 编写聚焦任务
- 03并行分派调查任务
- 04审查结果并整合修复
- 05运行完整测试验证
适用场景
- 01并行调查不同测试文件的失败
- 02分别排查互不相关的子系统故障
- 03在修复后检查代码变更冲突
- 04整合多项独立修复并验证
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ qodex-ai/ ai-agent-skills --skill distributed-task-execution安装后在 Claude Code 中输入/distributed-task-execution确认已加载。
详细介绍
调度并行 Agent
概述
当你遇到多个互不相关的失败(不同的测试文件、不同的子系统、不同的缺陷)时,逐个调查会浪费时间。每个调查都是独立的,可以并行进行。
核心原则: 每个独立的问题域调度一个 Agent。让它们并发工作。
何时使用
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 个以上测试文件失败,且根因各不相同
- 多个子系统独立出现故障
- 每个问题无需其他问题的上下文即可理解
- 各调查之间没有共享状态
不使用场景:
- 失败之间存在关联(修复一个可能修复其他)
- 需要理解整个系统状态
- Agent 之间会相互干扰
模式
1. 识别独立的问题域
按损坏的内容对失败进行分组:
- 文件 A 测试:工具审批流程
- 文件 B 测试:批量完成行为
- 文件 C 测试:中止功能
每个问题域都是独立的 —— 修复工具审批不会影响中止测试。
2. 创建聚焦的 Agent 任务
每个 Agent 获得:
- 明确范围: 一个测试文件或子系统
- 清晰目标: 让这些测试通过
- 约束条件: 不要修改其他代码
- 预期输出: 你发现并修复的内容摘要
3. 并行调度
// In Claude Code / AI environment
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")
// All three run concurrently
4. 审查并集成
当 Agent 返回时:
- 阅读每份摘要
- 验证修复之间没有冲突
- 运行完整测试套件
- 集成所有更改
Agent 提示词结构
好的 Agent 提示词应:
- 聚焦 —— 一个清晰的问题域
- 自包含 —— 包含理解问题所需的全部上下文
- 明确输出 —— Agent 应该返回什么?
Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
1. "should abort tool with partial output capture" - expects 'interrupted at' in message
2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed
3. "should properly track pendingToolCount" - expects 3 results but gets 0
These are timing/race condition issues. Your task:
1. Read the test file and understand what each test verifies
2. Identify root cause - timing issues or actual bugs?
3. Fix by:
- Replacing arbitrary timeouts with event-based waiting
- Fixing bugs in abort implementation if found
- Adjusting test expectations if testing changed behavior
Do NOT just increase timeouts - find the real issue.
Return: Summary of what you found and what you fixed.
常见错误
❌ 过于宽泛: "修复所有测试" —— Agent 会迷失方向 ✅ 具体明确: "修复 agent-tool-abort.test.ts" —— 范围聚焦
❌ 没有上下文: "修复竞态条件" —— Agent 不知道在哪里 ✅ 提供上下文: 粘贴错误信息和测试名称
❌ 没有约束: Agent 可能会重构所有内容 ✅ 约束条件: "不要修改生产代码" 或 "只修复测试"
❌ 输出模糊: "修复它" —— 你不知道改了什么 ✅ 具体明确: "返回根因和更改的摘要"
何时不要使用
相关联的失败: 修复一个可能修复其他 —— 先一起调查 需要完整上下文: 理解问题需要查看整个系统 探索性调试: 你还不清楚哪里坏了 共享状态: Agent 会相互干扰(编辑相同文件、使用相同资源)
会话中的真实示例
场景: 大规模重构后,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:添加了等待异步工具执行完成
集成: 所有修复相互独立,无冲突,完整套件通过
节省的时间: 3 个问题并行解决,而非顺序解决
主要优势
- 并行化 —— 多个调查同时进行
- 聚焦 —— 每个 Agent 范围窄,需要跟踪的上下文更少
- 独立性 —— Agent 之间互不干扰
- 速度 —— 用 1 个问题的时间解决 3 个问题
验证
当 Agent 返回后:
- 审查每份摘要 —— 理解改了什么
- 检查冲突 —— Agent 是否编辑了相同的代码?
- 运行完整套件 —— 验证所有修复协同工作
- 抽查 —— Agent 可能会犯系统性错误
真实场景影响
来自调试会话(2025-10-03):
- 3 个文件中共 6 处失败
- 3 个 Agent 并行派发
- 所有调查同时完成
- 所有修复均成功集成
- Agent 变更之间零冲突