Introduction
可以使用 subagents 将任务委托给聊天会话中具有其自己的上下文窗口的独立代理。 subagent 独立运行,无需等待用户反馈,并且将最终结果返回给主聊天会话。
Subagents 最适合以下情况:
- 你想要委托复杂的多步骤任务,如研究或分析,而不会中断主会话。
- 你需要处理大量的信息或多个文档,这些文档会混乱主上下文窗口。
- 你希望在不将上下文混合在一起的情况下独立探索不同的方法或透视。
Subagents 使用与主会话相同的工具和 AI 模型,但它们无法创建其他 subagents。
Subagents are available in Visual Studio Code, JetBrains IDEs, Xcode, and Eclipse. They are not currently available in Visual Studio. The steps to enable and invoke them differ by editor, so click the tabs above for instructions for your IDE.
For the agent session that subagents are delegated from, see Using agent mode in your IDE.
Enabling subagents
- In the Copilot Chat window, click the tools icon.
- Enable the
runSubagenttool.
If you use custom prompt files or custom agents, ensure you specify the runSubagent tool in the tools frontmatter property. See 为Copilot cloud agent创建自定义代理, and Use prompt files in VS Code in the Visual Studio Code documentation.
Invoking 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. -
Calling the #runSubagent tool.
Evaluate the #file:databaseSchema using #runSubagent and generate an optimized data-migration plan.
When the subagent completes its task, its results appear back in the main chat session, ready for follow-up questions or next steps.
Further reading
To use subagents, you must have custom agents configured in your environment. See Using custom agents in your IDE.
Enabling subagents
- Click Tools in the menu bar, then click GitHub Copilot, then Edit Settings.
- In the popup menu, click Chat, then click the Enable Subagent checkbox.
Invoking 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.
When the subagent completes its task, its results appear back in the main chat session, ready for follow-up questions or next steps.
Further reading
To use subagents, you must have custom agents configured in your environment. See Using custom agents in your IDE.
Enabling subagents
- Click Editor in the menu bar, then click GitHub Copilot then Open GitHub Copilot for Xcode Settings.
- Click Advanced in the chat panel, then under Chat Settings click the Enable Subagents toggle.
Invoking 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.
When the subagent completes its task, its results appear back in the main chat session, ready for follow-up questions or next steps.
Further reading
To use subagents, you must have custom agents configured in your environment. See Using custom agents in your IDE.
Enabling subagents
- Click the icon in the status bar.
- In the popup menu, click Edit Preferences.
- Under Chat, click the Enable sub-agent check box.
Invoking 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.
When the subagent completes its task, its results appear back in the main chat session, ready for follow-up questions or next steps.