Introduction
You can use subagents to delegate tasks to an isolated agent with its own context window within your chat session. The subagent operates independently without pausing for user feedback and returns the final result to the main chat session.
Subagents are best suited for situations where:
- You want to delegate complex, multi-step tasks like research or analysis without interrupting your main session.
- You need to process large amounts of information or multiple documents that would clutter your primary context window.
- You want to explore different approaches or perspectives independently without mixing contexts together.
Subagents use the same tools and AI model as the main session, but they cannot create other 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 Creating custom agents for Copilot cloud agent, and Use prompt files in VS Code in the Visual Studio Code documentation.
Invoking subagents
Subagents can be invoked in different ways:
-
Automatic delegation. Copilot will analyze the description of your request, the description field of your configured custom agents, and the current context and available tools to automatically choose a subagent. For example, this prompt would automatically delegate the task to a refactor-specialist custom agent:
Suggest ways to refactor this legacy code. -
Direct invocation. You can directly call the subagent in your prompt:
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 can be invoked in different ways:
-
Automatic delegation. Copilot will analyze the description of your request, the description field of your configured custom agents, and the current context and available tools to automatically choose a subagent. For example, this prompt would automatically delegate the task to a refactor-specialist custom agent:
Suggest ways to refactor this legacy code. -
Direct invocation. You can directly call the subagent in your prompt:
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 can be invoked in different ways:
-
Automatic delegation. Copilot will analyze the description of your request, the description field of your configured custom agents, and the current context and available tools to automatically choose a subagent. For example, this prompt would automatically delegate the task to a refactor-specialist custom agent:
Suggest ways to refactor this legacy code. -
Direct invocation. You can directly call the subagent in your prompt:
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 can be invoked in different ways:
-
Automatic delegation. Copilot will analyze the description of your request, the description field of your configured custom agents, and the current context and available tools to automatically choose a subagent. For example, this prompt would automatically delegate the task to a refactor-specialist custom agent:
Suggest ways to refactor this legacy code. -
Direct invocation. You can directly call the subagent in your prompt:
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.