Orchestrating GitHub Copilot Custom Agents in VS Code
GitHub Copilot custom agents make it possible to move beyond a single “do everything” assistant. Instead, you can design workflows where multiple agents collaborate, each focused on a specific responsibility.
In this post, I’ll walk through three orchestration modes you can use today when building custom agents in VS Code:
- VS Code agent handoffs
- Explicit subagent delegation
- Automatic subagent delegation
1. VS Code Agent Handoffs
Agent handoffs allow one agent to explicitly transfer control to another agent inside VS Code. The key point is that the handoff is visible and intentional, both for the agent and for the user.
A common example is separating general coding assistance from specialist reviews. The main agent stays responsible for the overall interaction, but temporarily hands control to a security‑focused agent for a deeper analysis.
Key Characteristics
- The transition is explicit and user‑driven
- Context and conversation history are preserved
- The user stays in control of when and why a handoff happens
Example
A user asks: “Scan my code for security issues.”
This pattern works well when you want a clear human‑in‑the‑loop moment, such as reviews, approvals, or sensitive checks.
2. Custom Agent-to-Agent Subagent Delegation
With explicit subagent delegation, a primary agent programmatically invokes other custom agents to handle well‑defined subtasks. Unlike handoffs, the user does not switch agents. The orchestration happens behind the scenes.
This is useful when you have a repeatable workflow with clear responsibilities, and you want each agent to stay focused on a single concern.
Key Characteristics
- The primary agent controls orchestration via APIs
- Subagents run autonomously and return results
- Tasks can run in parallel or in a defined sequence
Example
A DevOps‑focused agent orchestrates a deployment pipeline:
- Code linting is delegated to a linter agent
- Tests are delegated to a test agent
- Packaging is delegated to a build agent
The main agent collects the results and presents a single, consolidated outcome to the user.
This approach maps well to CI/CD pipelines and other structured automation scenarios.
3. Automatic Delegation to Subagents
Automatic delegation pushes orchestration a step further. Instead of relying on predefined rules or explicit calls, the agent decides at runtime whether a subagent is needed.
The decision can be based on context such as project structure, detected issues, or the current stage of the workflow.
What changes here
- The agent decides when and which subagent to invoke
- Delegation is driven by intent and context, not static configuration
- Workflows adapt dynamically as conditions change
Example
A user says: “Deploy my app.”
The main agent inspects
the project and notices that tests are missing. Before deploying, it
automatically invokes a test agent, waits for the results, and only
proceeds if the outcome is acceptable without the user explicitly
asking for this step.
This pattern is useful when you want intelligent defaults and minimal user intervention for routine tasks.
Choosing the Right Orchestration Mode
Decision Framework
Human-in-the-loop
Context preserved] DelegationMode --> DelegationDetails["Modular workflow
Clear boundaries
Parallel execution"] AutoMode --> AutoDetails[Adaptive behavior
Runtime decisions
Dynamic workflows] ```
Comparison Matrix
When to Use Each Mode
Agent handoffs
- You want explicit user visibility and approval
- Human oversight is important
- The task benefits from specialist context
Example: Main agent suggests handing off to a security agent for review.
Subagent delegation
- The workflow has clear, repeatable stages
- Multiple specialized tasks need coordination
- Tasks can run in parallel or in sequence
Example: Lint → test → build → deploy pipeline.
Automatic delegation
- The agent should adapt based on context
- The workflow depends on project structure or state
- You want fewer manual decisions for routine work
Example: Deployment agent automatically invokes tests or security checks when needed.
Try It Yourself
If you want to explore these orchestration styles hands-on, see the accompanying repository:
https://github.com/royarin/github-copilot-agent-orchestration
The repository contains concrete examples for agent handoffs, explicit subagent delegation, and automatic delegation, making it easier to experiment with and compare the different patterns in practice.
Conclusion
Custom agents are not just about adding more capabilities to GitHub Copilot, they’re about structuring responsibility. The orchestration model you choose determines how much control you keep, how predictable your workflows are, and how much autonomy you delegate to the agent.
Agent handoffs work best when humans need to stay in the loop. Explicit subagent delegation shines in structured, repeatable pipelines. Automatic delegation becomes powerful when you want the agent to adapt to context and make sensible decisions on your behalf.
In practice, most real-world solutions will combine these patterns. The goal isn’t to pick a single “best” approach, but to use the right orchestration style at the right point in the workflow.
Comments
Post a Comment