介绍
可以使用 subagents 将任务委托给聊天会话中具有其自己的上下文窗口的独立代理。 subagent 独立运行,无需等待用户反馈,并且将最终结果返回给主聊天会话。
Subagents 最适合以下情况:
- 你想要委托复杂的多步骤任务,如研究或分析,而不会中断主会话。
- 你需要处理大量的信息或多个文档,这些文档会混乱主上下文窗口。
- 你希望在不将上下文混合在一起的情况下独立探索不同的方法或透视。
Subagents 使用与主会话相同的工具和 AI 模型,但它们无法创建其他 subagents。
Subagents 可在 Visual Studio Code、JetBrains 各 IDE、Xcode 和 Eclipse 中使用。 它们目前在 Visual Studio 中不可用。 启用和调用它们的步骤因编辑器而异,因此请单击上面的选项卡以获取 IDE 的说明。
有关从中委托的代理会话 subagents ,请参阅 在 IDE 中使用代理模式。
启用 subagents
- 在 Copilot Chat 窗口中,单击工具图标。
runSubagent启用该工具。
如果使用自定义提示文件或custom agents,请确保在runSubagent的 frontmatter 属性中指定tools工具。 请参阅中的AUTOTITLE,以及Visual Studio Code。
调用 subagents
Subagents 可以以不同的方式进行调用:
-
自动委派。 Copilot 将分析您的请求说明、配置的 custom agents 的说明字段,以及当前上下文和可用工具,以便自动选择一个 subagent。 例如,此提示会自动将任务委托给 重构专家 custom agent:
Suggest ways to refactor this legacy code. -
直接调用。 可以在提示中直接调用 subagent:
Use the testing subagent to write unit tests for the authentication module. -
调用 #runSubagent 工具。
Evaluate the #file:databaseSchema using #runSubagent and generate an optimized data-migration plan.
subagent完成任务后,其结果会显示在主聊天会话中,并准备好跟进问题或后续步骤。
延伸阅读
若要使用 subagents,必须在环境中配置 custom agents。 请参阅“在 IDE 中使用自定义代理”。
启用 subagents
- 在菜单栏中单击 “工具”,然后单击“GitHub Copilot****编辑设置”。
- 在弹出菜单中,单击“ 聊天”,然后单击“ 启用 Subagent ”复选框。
调用 subagents
Subagents 可以以不同的方式进行调用:
-
自动委派。 Copilot 将分析您的请求说明、配置的 custom agents 的说明字段,以及当前上下文和可用工具,以便自动选择一个 subagent。 例如,此提示会自动将任务委托给 重构专家 custom agent:
Suggest ways to refactor this legacy code. -
直接调用。 可以在提示中直接调用 subagent:
Use the testing subagent to write unit tests for the authentication module.
subagent完成任务后,其结果会显示在主聊天会话中,并准备好跟进问题或后续步骤。
延伸阅读
若要使用 subagents,必须在环境中配置 custom agents。 请参阅“在 IDE 中使用自定义代理”。
启用 subagents
- 在菜单栏中单击Editor,然后单击GitHub Copilot 然后打开 GitHub Copilot for Xcode 设置。
- 在聊天面板中单击“ 高级 ”,然后在 “聊天设置” 下单击“ 启用 Subagents ”开关。
调用 subagents
Subagents 可以以不同的方式进行调用:
-
自动委派。 Copilot 将分析您的请求说明、配置的 custom agents 的说明字段,以及当前上下文和可用工具,以便自动选择一个 subagent。 例如,此提示会自动将任务委托给 重构专家 custom agent:
Suggest ways to refactor this legacy code. -
直接调用。 可以在提示中直接调用 subagent:
Use the testing subagent to write unit tests for the authentication module.
subagent完成任务后,其结果会显示在主聊天会话中,并准备好跟进问题或后续步骤。
延伸阅读
若要使用 subagents,必须在环境中配置 custom agents。 请参阅“在 IDE 中使用自定义代理”。
启用 subagents
- 单击状态栏中的 图标。
- 在弹出菜单中,单击“ 编辑首选项”。
- 在 “聊天”下,单击“ 启用子代理 ”复选框。
调用 subagents
Subagents 可以以不同的方式进行调用:
-
自动委派。 Copilot 将分析您的请求说明、配置的 custom agents 的说明字段,以及当前上下文和可用工具,以便自动选择一个 subagent。 例如,此提示会自动将任务委托给 重构专家 custom agent:
Suggest ways to refactor this legacy code. -
直接调用。 可以在提示中直接调用 subagent:
Use the testing subagent to write unit tests for the authentication module.
subagent完成任务后,其结果会显示在主聊天会话中,并准备好跟进问题或后续步骤。