IDE 中的 Subagents
启用子智能体工具,把独立分析交给隔离上下文并回收结果。
This page has not been translated into English yet. The original Chinese version is shown below.
Subagent 在主 Chat 会话内接收一个独立子任务,使用自己的上下文完成工作,再把最终结果返回主会话。它适合研究、分析大量资料,或独立比较不同方案,避免把所有过程细节放进主上下文。
当前行为与支持范围
GitHub 的 IDE 专题说明:subagent 使用主会话相同的工具和 AI 模型,不会暂停等待用户反馈,也不能继续创建其他 subagent。这里描述的是 IDE 体验,不能与 CLI 的嵌套层数、并发或独立模型配置混为一谈。
支持 VS Code、JetBrains、Xcode、Eclipse,当前不支持 Visual Studio。JetBrains、Xcode、Eclipse 还要求先配置自定义智能体。
启用方式
| 编辑器 | 操作 |
|---|---|
| VS Code | Chat 工具按钮中启用 runSubagent;使用 custom prompt 或 agent 时还要在 tools frontmatter 中包含该工具 |
| JetBrains | Tools → GitHub Copilot → Edit Settings → Chat,勾选 Enable Subagent |
| Xcode | Editor → GitHub Copilot → Open GitHub Copilot for Xcode Settings → Advanced → Chat Settings,开启 Enable Subagents |
| Eclipse | 状态栏 Copilot → Edit Preferences → Chat,勾选 Enable sub-agent |
委派任务
主会话可以根据请求、custom agent 的 description、上下文和可用工具自动决定委派。也可以直接写明希望使用哪个子智能体,例如:
Use the testing subagent to write unit tests for the authentication module.VS Code 还支持明确引用工具:
Evaluate the #file:databaseSchema using #runSubagent and generate an optimized data-migration plan.此语法是 VS Code 专题给出的示例,不保证其他 IDE 也接受 #runSubagent。
接收与检查结果
子任务完成后,结果返回主 Chat,会话可以继续追问或推进下一步。委派时写清输入范围与预期输出,回收结果后检查依据和未确认事项;隔离上下文并不等于结果天然正确,也不是另一套文件访问授权机制。