Dung (Donny) Nguyen

Senior Software Engineer

The Benefits of Using Multiple Agents and How to Set Them Up in GitHub Copilot for VS Code

Introduction

GitHub Copilot’s agent mode can autonomously plan and execute multi-step coding tasks. But a single, general-purpose agent is not always the best tool for every job. As projects grow in complexity, using multiple specialized agents—each with a focused role, a curated set of tools, and its own instructions—can dramatically improve reliability, speed, and quality. This article explains the benefits of using multiple agents and walks through how to set them up in GitHub Copilot for VS Code.

What Are Multiple Agents?

In VS Code, an agent (formerly called a custom chat mode) is a configurable persona for Copilot. Each agent can define:

Instead of relying on one do-everything assistant, you compose a small team of agents and route each task to the most appropriate one. You can even have a coordinating agent delegate work to specialized sub-agents.

Benefits of Using Multiple Agents

1. Focused Expertise

A specialized agent stays on task. A “Test Engineer” agent primed with your testing conventions will write more consistent, higher-quality tests than a general agent that has to juggle many concerns at once.

2. Reduced Context Noise

Each agent carries only the instructions and tools relevant to its role. This keeps its context window focused, which improves accuracy and reduces the chance of the model wandering off task.

3. Safer, Scoped Permissions

You can restrict which tools an agent may use. A read-only “Code Reviewer” agent can be prevented from editing files or running destructive terminal commands, while an “Implementer” agent is granted broader permissions. This limits the blast radius of mistakes.

4. Parallelism and Delegation

A coordinating agent can break a large task into independent pieces and dispatch them to sub-agents. Research, refactoring, and test generation can proceed without cluttering the main conversation, and results are summarized back to you.

5. Reusability and Consistency

Agent definitions are files you can commit to source control. Your whole team shares the same specialized behaviors, ensuring consistent output across contributors and machines.

6. Easier Debugging and Iteration

When an agent misbehaves, you only need to adjust that agent’s focused instructions—rather than untangling one giant prompt that tries to do everything.

How to Set Up Multiple Agents in VS Code

GitHub Copilot supports custom agents through custom agent files (.agent.md) and supporting instruction files.

Note: Custom agents were previously known as custom chat modes. If you have older .chatmode.md files, rename them to .agent.md and move them into the .github/agents/ folder to keep using them.

Step 1: Open Agent Mode

  1. Open the Chat view (Ctrl+Alt+I / Cmd+Ctrl+I).
  2. Use the agent picker at the top of the chat input to choose between the built-in agents and any custom agents you create.

Step 2: Create a Custom Agent

The simplest way is from the Chat view or the Command Palette:

  1. In the Chat view, select Configure Chat (the gear icon) to open the Agent Customizations editor, then open the Agents tab. (You can also type /agents in the chat input, or run Chat: Open Customizations from the Command Palette.)
  2. Select New Agent (Workspace) or New Agent (User) from the dropdown, depending on where you want to store the agent. Alternatively, run Chat: New Custom Agent from the Command Palette (Ctrl+Shift+P / Cmd+Shift+P).
  3. Choose the location and enter a name, such as test-engineer.

Workspace agents are stored in .github/agents/, and user-level agents are available across all your workspaces. This creates a file like:

your-repo/
└── .github/
    └── agents/
        └── test-engineer.agent.md

Tip: VS Code detects any .md file in the .github/agents/ folder as a custom agent. You can also generate one with AI by typing /create-agent in Agent mode and describing the persona you want.

Step 3: Define the Agent

A custom agent file uses YAML front matter for configuration, followed by Markdown instructions.

Example test-engineer.agent.md:

---
description: 'Writes and runs unit tests following project conventions.'
tools: ['codebase', 'search', 'editFiles', 'runTests', 'terminal']
model: Claude Sonnet 4.5
---

# Test Engineer

You are a specialized test-writing assistant.

- Follow the existing test framework and folder structure.
- Write clear, deterministic tests with descriptive names.
- Cover edge cases and error paths.
- After writing tests, run them and fix any failures.
- Do not modify production code unless a test reveals a genuine bug—flag it first.

Key front matter fields:

Step 4: Create Additional Specialized Agents

Repeat the process to build a small team. For example:

code-reviewer.agent.md (read-only):

---
description: 'Reviews code for bugs, security, and style. Read-only.'
tools: ['codebase', 'search', 'usages', 'problems']
---

# Code Reviewer

You review code without modifying it.

- Identify bugs, security issues (OWASP Top 10), and style violations.
- Reference specific files and line numbers.
- Suggest concrete fixes, but do not edit files.

doc-writer.agent.md:

---
description: 'Writes and updates project documentation.'
tools: ['codebase', 'search', 'editFiles']
---

# Documentation Writer

You write clear, accurate documentation.

- Match the existing tone and formatting.
- Keep examples runnable and correct.
- Update related index or table-of-contents files when adding new docs.

Step 5: Share Instructions Across Agents

For rules that apply to every agent, use a repository-wide instructions file so you do not repeat yourself:

your-repo/
└── .github/
    └── copilot-instructions.md

This file is automatically included as context. Agent-specific files then layer additional, role-specific guidance on top.

Step 6: Switch Between Agents

Once created, your custom agents appear in the agent picker at the top of the Chat view. Select the agent that matches your current task—test-engineer, code-reviewer, or doc-writer—and Copilot adopts that persona, tools, and instructions. You can also use handoffs to move from one agent to the next in a guided workflow (for example, planning → implementation → review).

Best Practices

Conclusion

Using multiple specialized agents turns GitHub Copilot from a single generalist into a coordinated team of experts. The result is more focused expertise, safer permissions, cleaner context, and consistent, reusable behavior across your project. By defining custom chat mode files in VS Code and layering shared instructions, you can build a lightweight agent team tailored to your workflow—and let each task go to the agent best suited to solve it.