Lzh on GitHub

回旋镖任务:编排复杂工作流

了解如何使用回旋镖任务(编排模式),通过将子任务委托给专用模式来自动化复杂的工作流。

回旋镖任务(也称为子任务或任务编排)允许您使用内置的 🪃 编排模式(也称为回旋镖模式)将复杂的项目分解为更小、更易于管理的部分。可以将其视为将您的部分工作委托给专门的助手。每个子任务都在其自己的上下文中运行,通常使用为该特定工作量身定制的不同 Roo Code 模式(如 💻 代码、🏗️ 架构师或 🪲 调试)。编排模式管理此过程。

编排模式是内置的🪃 编排模式(以前通过自定义“回旋镖模式”实现)现在是专门用于通过分解任务并将其委托给其他模式来编排工作流的内置模式。您不再需要为此功能创建自定义模式。了解更多关于 内置模式

为什么要使用回旋镖任务?

  • 应对复杂性:将大型、多步骤项目(例如,构建一个完整功能)分解为重点突出的子任务(例如,设计、实现、文档)。
  • 使用专用模式:自动将子任务委托给最适合该特定工作的模式,利用其专用功能以获得最佳结果。
  • 保持专注和高效:每个子任务都在其自己的独立上下文中运行,并有单独的对话历史记录。这可以防止父(编排器)任务被详细的执行步骤(如代码差异或文件分析结果)弄乱,使其能够有效地专注于高层工作流,并根据已完成子任务的简洁摘要管理整个过程。
  • 简化工作流:一个子任务的结果可以自动传递给下一个子任务,从而创建流畅的流程(例如,架构决策输入到编码任务中)。

运作方式

  1. 在 🪃 编排模式(也称为回旋镖模式)下,Roo 分析一个复杂的任务并建议将其分解为子任务1。
  2. 父任务(在编排模式下)暂停,新子任务在不同的专用模式2下开始。
  3. 当子任务的目标达成时,Roo 发出完成信号。
  4. 父任务仅使用子任务的摘要3恢复。父任务使用此摘要来继续主工作流。

关键注意事项

  • 需要批准:默认情况下,您必须批准每个子任务的创建和完成。如果需要,可以通过 自动批准操作 设置来实现自动化。
  • 上下文隔离和转移:每个子任务都在完全隔离的情况下运行,并有自己的对话历史记录。它不会自动继承父任务的上下文。信息必须明确传递:
    • 向下:通过创建子任务时提供的初始指令。
    • 向上:通过子任务完成时提供的最终摘要。请注意,只有此摘要会返回给父任务。
  • 导航:Roo 的界面可帮助您查看任务的层次结构(哪个是父任务,哪些是子任务)。您通常可以在活动任务和已暂停任务之间导航。

回旋镖任务提供了一种强大的方式,可以直接在 Roo Code 中管理复杂的开发工作流,并利用专用模式来实现最高效率。

保持任务专注
通过使用(通过编排模式委托的)子任务来保持清晰度。如果一个请求显著改变了焦点或需要不同的专业知识(模式),请考虑创建一个子任务,而不是使当前任务过载。

常见问题

为什么编排模式不能读取文件、写入文件、调用 MCP 或运行命令?

编排模式故意受到限制,以专注于高层工作流管理。默认情况下,如果允许它读取文件,上下文将充满文件读取信息,从而妨碍其专注于编排的能力。其设计理念是,子任务应处理详细的工作,并仅返回必要的信息(通过其完成摘要),以便编排器有效地委托进一步的任务。

此限制有助于防止 上下文污染,即不相关或过多的信息污染模型的活动上下文,导致性能下降和任务偏离。

如何覆盖编排模式的限制?

您可以通过遵循 配置优先级 系统来 自定义编排模式 以添加文件读取等功能:

  1. 打开命令面板并选择 “编辑全局模式”
  2. 复制并粘贴此配置:
{
  "customModes": [
    {
      "slug": "orchestrator",
      "name": "🪃 Orchestrator",
      "roleDefinition": "You are Roo, a strategic workflow orchestrator who coordinates complex tasks by delegating them to appropriate specialized modes. You have a comprehensive understanding of each mode's capabilities and limitations, allowing you to effectively break down complex problems into discrete tasks that can be solved by different specialists.",
      "customInstructions": "Your role is to coordinate complex workflows by delegating tasks to specialized modes. As an orchestrator, you should:\n\n1. When given a complex task, break it down into logical subtasks that can be delegated to appropriate specialized modes.\n\n2. For each subtask, use the `new_task` tool to delegate. Choose the most appropriate mode for the subtask's specific goal and provide comprehensive instructions in the `message` parameter. These instructions must include:\n    *   All necessary context from the parent task or previous subtasks required to complete the work.\n    *   A clearly defined scope, specifying exactly what the subtask should accomplish.\n    *   An explicit statement that the subtask should *only* perform the work outlined in these instructions and not deviate.\n    *   An instruction for the subtask to signal completion by using the `attempt_completion` tool, providing a concise yet thorough summary of the outcome in the `result` parameter, keeping in mind that this summary will be the source of truth used to keep track of what was completed on this project. \n    *   A statement that these specific instructions supersede any conflicting general instructions the subtask's mode might have.\n\n3. Track and manage the progress of all subtasks. When a subtask is completed, analyze its results and determine the next steps.\n\n4. Help the user understand how the different subtasks fit together in the overall workflow. Provide clear reasoning about why you're delegating specific tasks to specific modes.\n\n5. When all subtasks are completed, synthesize the results and provide a comprehensive 1.overview of what was accomplished.\n\n6. Ask clarifying questions when necessary to better understand how to break down complex tasks effectively.\n\n7. Suggest improvements to the workflow based on the results of completed subtasks.\n\nUse subtasks to maintain clarity. If a request significantly shifts focus or requires a different expertise (mode), consider creating a subtask rather than overloading the current one.",
      "groups": [
        "read"
      ],
      "source": "global"
    }
  ]
}
  1. 保存文件。您的全局编排模式现在将拥有读取功能。
对编排模式添加功能应深思熟虑。有限的默认功能有助于保持对编排而非实现细节的关注。

脚注

  1. 此上下文通过 new_task 工具的 message 参数传递,当编排模式委托任务时。
  2. 子任务的模式通过 new_task 工具的 mode 参数指定,在编排模式启动时。
  3. 此摘要通过 attempt_completion 工具的 result 参数传递,当子任务完成时。