Three-tier agents in VS Code with GitHub Copilot
Purpose
This guide reproduces a three-tier agent workflow in Visual Studio Code with GitHub Copilot:
- 1. Coordinator and reviewer: Claude Opus 5.5 understands the request, decides the architecture and reviews the final diff.
- 2. Implementation worker: Claude Haiku 5.5 makes the change, runs the checks and reports back.
- 3. Mechanical assistant: GPT-6 Luna handles tightly bounded, repetitive work at the lowest cost.
The design keeps architecture and final review with the strongest model, implementation with a cheaper coding model, and repetitive evidence-gathering or editing with the lowest-cost suitable model. The roles match the tool-agnostic split in Building AI agents; this page is the VS Code and Copilot implementation. OpenCode and Claude Code use the same roles with their own file formats, documented in OpenCode agents and Claude Code subagents.
Final architecture
Claude Opus 5.5 └── implementation-worker: Claude Haiku 5.5 └── mechanical-worker: GPT-6 Luna
Responsibilities
Claude Opus 5.5
- Understand the full request.
- Decide architecture and ownership.
- Delegate implementation to implementation-worker.
- Review the complete diff independently.
- Check regressions, tests, repository rules, and unintended changes.
- Return precise corrections to the worker.
- Decide when the result is satisfactory.
Claude Haiku 5.5
- Inspect the repository and applicable instructions.
- Implement the smallest complete change.
- Run appropriate linters and tests.
- Preserve pre-existing work.
- Delegate only exact mechanical tasks to mechanical-worker.
- Verify mechanical-worker output before reporting to Opus.
GPT-6 Luna
- Perform literal searches and inventories.
- Run exact commands supplied by Haiku.
- Apply explicitly specified repetitive edits.
- Run narrow formatters, linters, or tests.
- Summarize command output without changing its meaning.
- Never make architecture, ownership, or migration decisions.
Prerequisites
- Visual Studio Code with the GitHub Copilot setup.
- Access to the Local agent harness.
- The following models enabled in the VS Code model picker: Claude Opus 5.5, Claude Haiku 5.5, GPT-6 Luna.
- A trusted local workspace.
- Permission to use the selected models for the data classification and software activity involved.
Use only models approved by the organization that manages the Copilot account. Do not substitute personal API keys or unapproved external model extensions. Follow the organization’s current AI-tool, data-classification, privacy, export-control, and regulated-software requirements.
Start the coordinator session
- 1. Open the Chat view with Ctrl+Alt+I.
- 2. Start a new chat with Ctrl+N while the Chat view is focused.
- 3. Set Session Target to Local.
- 4. Set the main model to Claude Opus 5.5.
- 5. Set permissions to Allow all only if the workspace and task are trusted.
- 6. Keep the main interaction mode set to Agent.
Allow all removes per-action approval prompts, but VS Code can still pause when the configured maximum number of model or tool requests is reached. Use Continue to resume a legitimate long-running task, or adjust Configure max requests carefully.
Create the implementation worker
Create this user-level file:
mkdir -p ~/.config/Code/User/prompts
vi ~/.config/Code/User/prompts/implementation-worker.agent.md
--- name: implementation-worker model: Claude Haiku 5.5 description: "General implementation worker subagent. Use when the Claude Opus 5.5 coordinator delegates a coding task: inspect the repository, implement the requested change, run the right linters and tests, and report changed files, commands, results and open uncertainties. Also use to apply the coordinator's correction instructions after its review. Never commits, pushes or posts review comments." tools: [read, search, edit, execute, agent] agents: [mechanical-worker] user-invocable: false --- You are an implementation worker. The Claude Opus 5.5 coordinator delegates a coding task to you. You make the change, check it, and hand control back to the coordinator, which reviews your work. You do not decide what ships. ## Constraints - DO NOT run `git commit`, `git push`, `git commit --amend`, `git rebase`, `git reset`, `git checkout -- <file>`, `git restore`, `git stash`, `git clean`, or anything else that creates history or discards changes, yours or the user's. Read-only Git commands such as `status`, `diff`, `log`, `show`, and `blame` are allowed. - DO NOT post, edit, or resolve review comments, merge-request notes, Rally items, Teams messages, or emails. - DO NOT print secrets or credentials. - DO NOT widen the task, perform unrelated refactors, or fix unrelated pre-existing issues. - ONLY perform the delegated task or corrections from the coordinator. - Delegate only exact, bounded mechanical work to `mechanical-worker`. - Verify all delegated results before returning them to the coordinator. ## Approach 1. Read `CLAUDE.md`, `AGENTS.md`, included instructions, and repository guidelines first. 2. Inspect before editing. Check `git status --short` and the relevant diff. 3. Implement the smallest complete change matching surrounding style. 4. Run the narrowest checks that cover the change. 5. Return a structured report and stop for coordinator review. ## Corrections from the coordinator Apply only the requested corrections, rerun affected checks, and return a report describing the new round. If a correction conflicts with repository rules or these constraints, do not apply that part and explain why. ## Output format Return one Markdown report with: - Summary - Changed files - Commands run - Not run here - Pre-existing issues - Uncertainties and questions
Important configuration fields
model: Claude Haiku 5.5 tools: [read, search, edit, execute, agent] agents: [mechanical-worker] user-invocable: false
- model prevents the worker from inheriting Claude Opus 5.5.
- agent allows nested delegation.
- agents: [mechanical-worker] restricts delegation to the named worker.
- user-invocable: false hides the worker from normal direct selection.
Create the mechanical worker
Create this user-level file:
vi ~/.config/Code/User/prompts/mechanical-worker.agent.md
--- name: mechanical-worker model: GPT-6 Luna description: "Low-cost mechanical subagent for exact, bounded tasks delegated by the Claude Haiku 5.5 implementation worker. Use for literal searches, inventories, explicitly specified repetitive edits, formatting, and running exact commands. Never makes architectural decisions or expands task scope." tools: [read, search, edit, execute] user-invocable: false --- You are a mechanical worker subordinate to the Claude Haiku 5.5 implementation worker. Perform only the exact, bounded task provided by the implementation worker. Return the evidence or result to the implementation worker for verification. You do not decide what ships. ## Allowed work - Search for exact strings, paths, symbols, settings, routes, or filenames. - Inventory files, functions, tests, configuration, and references. - Run exact read-only commands requested by the implementation worker. - Make repetitive edits only when the implementation worker provides exact files, transformation, and acceptance criteria. - Run explicitly requested formatters, linters, or narrow tests. - Summarize command output without changing its meaning. ## Constraints - Do not make architectural, ownership, design, or migration decisions. - Do not interpret ambiguous requirements. Stop and report the ambiguity. - Do not widen the task or perform unrelated cleanup. - Do not create temporary scripts or files unless the implementation worker explicitly names and authorizes them. - Do not use the web or external services. - Do not delegate to another agent. - Do not post or modify GitLab, Rally, Teams, email, or review comments. - Do not print secrets or credentials. - Do not commit, push, amend, rebase, reset, restore, check out files, stash, clean, or stage files. - Do not delete, rename, or move files or directories unless the implementation worker explicitly authorizes the exact paths. - Before editing, inspect `git status --short` and preserve pre-existing work. - Preserve Robot Framework whitespace exactly. ## Reporting Return a concise Markdown report containing: - Task received - Files inspected - Files changed - Commands run and outcomes - Exact findings - Uncertainties or blocked items Do not claim success if any acceptance criterion was not verified.
The mechanical worker deliberately lacks the agent tool, so it cannot create another delegation layer.
Validate and test the chain
Validate the configuration
Open both agent files in VS Code and confirm:
- No YAML validation error is visible.
- The file contains plain Markdown, not copied HTML such as <br>, <strong>, or <file>.
- implementation-worker includes agent and agents: [mechanical-worker].
- mechanical-worker does not include agent.
- Both agents have user-invocable: false.
If VS Code was already running an agent session while the files were edited, start a new chat before testing. Existing subagent invocations can retain the old configuration.
Verify the Opus-to-Haiku delegation
Start a new Local session using Claude Opus 5.5 and Allow all. Submit this safe test:
Delegate a read-only repository inspection to the implementation-worker subagent. Ask the worker to report the repository path and current Git branch without editing any files. After the worker returns, review its report and tell me which model the subagent actually used.
Inspect the request details. Confirm:
- Main requests used Claude Opus 5.5.
- Worker requests used Claude Haiku 5.5.
- No files were edited.
Verify the Haiku-to-Luna delegation
In a fresh Local session, use a bounded read-only task:
Coordinate this test through implementation-worker. Ask implementation-worker to delegate this exact mechanical task to mechanical-worker: find all files named CLAUDE.md or AGENTS.md under the current workspace, report their paths, and do not edit anything. Implementation-worker must verify the returned paths before reporting to the Claude Opus 5.5 coordinator. The coordinator must then state which model served each level of the hierarchy.
Confirm in request details:
- Coordinator: Claude Opus 5.5
- Implementation worker: Claude Haiku 5.5
- Mechanical worker: GPT-6 Luna
- No files changed
Recommended production prompt
Coordinate this task using the implementation-worker subagent: [describe the task and acceptance criteria] Delegate implementation to the worker. The worker may delegate only exact, bounded mechanical tasks to mechanical-worker. The implementation worker must verify all mechanical-worker output. When the implementation worker finishes, independently review the complete diff for correctness, regressions, test coverage, repository conventions, and unintended changes. If changes are needed, send precise corrections back to the implementation worker and review the result again. Continue until the implementation is satisfactory. Do not commit, amend, rebase, push, reset, restore, clean, discard changes, or modify unrelated work.
Cost and model selection
In the VS Code picker used during this setup, GPT-6 Luna showed:
| Metric | Value |
|---|---|
| Cost tier | Low |
| Context | 272K, expandable to 872K |
| Input, credits per 1M tokens | 10 |
| Output, credits per 1M tokens | 50 |
| Cache read, credits per 1M tokens | 1 |
| Cache write, credits per 1M tokens | 12.5 |
Treat these values as account- and time-specific. Recheck the model-picker pricing on a new machine because model names, availability, context limits, and credit rates can change; verify current prices before budgeting.
A lower token price does not guarantee a lower completed-task cost. Compare representative tasks using Agent Debug Logs and measure retries, token usage, tool errors, duration, and review corrections.
Operational safeguards
- Keep destructive Git and filesystem actions out of all worker agents.
- Before commits or pushes, inspect Git state and perform those actions manually or through a separately controlled process.
- Require repository-specific instructions to override generic worker behavior.
- Keep mechanical tasks narrow enough to verify quickly.
- Do not allow a mechanical worker to invent scripts or temporary files without explicit authorization.
- Review the changed-files panel before selecting Keep.
- A VS Code Continue prompt can be a maximum-request limit, not a permission failure.
- Use Allow all only in trusted workspaces and only with carefully restricted agent instructions.
Troubleshooting
- Worker inherits the Opus model. Verify the worker header contains model: Claude Haiku 5.5, then start a new session after saving.
- Haiku cannot invoke Luna. Verify the Haiku worker contains tools: [read, search, edit, execute, agent] and agents: [mechanical-worker], and that mechanical-worker.agent.md exists in the same user prompts directory.
- Mechanical worker can create another subagent. Remove agent from its tools list. The expected list is tools: [read, search, edit, execute].
- Agent is visible in the main picker. Verify user-invocable: false.
- Copied file contains HTML. Replace HTML artifacts with plain Markdown. In particular, remove <br>, <strong>, CSS class attributes, and encoded text such as <file>.
- VS Code still asks for confirmation. Check whether the prompt is an action approval, controlled by the permission mode; a maximum-request pause, resolved with Continue or Configure max requests; or a survey or feedback prompt, unrelated to execution permissions.
References
- VS Code: Custom agents in VS Code
- VS Code: Custom agent file reference
- VS Code: Use subagents
- VS Code: Manage approvals and permissions
- VS Code: Optimize AI credit usage
Article author: Arthur Isaev