mcpField
D
dispatching-parallel-agents

dispatching-parallel-agents

github.com/jackspaceAgent 工作流1637 次安装12 周前更新
代码仓库

关于 dispatching-parallel-agents

Dispatching Parallel Agents 是一项用于协调多个 Agent 并行排查独立问题的技能。它提供将故障划分为具体任务、并发调查以及检查和整合结果的流程。

主要功能

  1. 01按独立领域归类故障
  2. 02制定聚焦的 Agent 任务
  3. 03并发分派调查
  4. 04审查修复并检查冲突
  5. 05运行完整测试套件

适用场景

  1. 01排查多个测试文件中的无关故障
  2. 02并行调试相互独立的子系统问题
  3. 03协调 Agent 修复并避免文件冲突

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/jackspace/claudeskillz --skill dispatching-parallel-agents

安装后在 Claude Code 中输入/dispatching-parallel-agents确认已加载。

附带文件SKILL.json

详细介绍

调度并行 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 提示词应:

  1. 聚焦 —— 一个清晰的问题域
  2. 自包含 —— 包含理解问题所需的全部上下文
  3. 明确输出 —— 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 个问题并行解决,而非顺序解决

主要优势

  1. 并行化 —— 多个调查同时进行
  2. 聚焦 —— 每个 Agent 范围窄,需要跟踪的上下文更少
  3. 独立性 —— Agent 之间互不干扰
  4. 速度 —— 用 1 个问题的时间解决 3 个问题

验证

当 Agent 返回后:

  1. 审查每份摘要 —— 理解改了什么
  2. 检查冲突 —— Agent 是否编辑了相同的代码?
  3. 运行完整套件 —— 验证所有修复协同工作
  4. 抽查 —— Agent 可能会犯系统性错误

真实场景影响

来自调试会话(2025-10-03):

  • 3 个文件中共 6 处失败
  • 3 个 Agent 并行派发
  • 所有调查同时完成
  • 所有修复均成功集成
  • Agent 变更之间零冲突

评论

支持 Markdown