Intermediate

Agent Mode

Agent mode transforms Copilot from a reactive assistant into an autonomous worker. Instead of responding to one question at a time, it plans a sequence of actions, edits multiple files, runs terminal commands, reads error output, and iterates until the task is done — all without you approving each individual step. You describe the outcome; Copilot figures out the steps.

How Agent Mode Works

1
You describe the task

Write a natural language description of what you want done — 'add pagination to the user list API endpoint'

2
Copilot plans

Copilot reads the relevant files, understands the codebase structure, and determines which files need to change and in what order

3
Execute edits

Copilot makes changes across multiple files — models, controllers, tests, configuration — in sequence

4
Run and verify

Runs terminal commands (tests, builds, linters) and reads their output to check if the changes work correctly

5
Iterate on failures

If a test fails or a build errors, Copilot reads the error, adjusts the code, and tries again — without asking you each time

What It Can Do

Multi-file edits

Change an API endpoint, update its tests, adjust the client-side call, and update relevant types — all in one task.

Terminal commands

Run `npm test`, `pytest`, `cargo build`, or any shell command and read the output to verify success.

Scaffold features

Create a new feature from scratch — new files, routes, components, tests — based on a description of what it should do.

Refactoring

Rename a function across all usages, extract a class, migrate from one library to another, apply a new pattern project-wide.

Bug investigation

Given a failing test or error, trace through the code to find the root cause and fix it, running tests after to confirm.

Dependency updates

Update a package, scan for breaking changes, apply fixes across all affected files, verify tests pass.

How to Use It in VS Code

  1. Open the Copilot Chat panel (Ctrl+Shift+P → “GitHub Copilot: Open Chat”)
  2. Click the mode selector at the top of the chat — switch from Ask to Agent
  3. Type your task description — be specific about what outcome you want, not how to achieve it
  4. Copilot will show a plan and begin making edits — you can watch the changes in real time in the editor
  5. You can pause, undo changes, or redirect mid-task if the approach is wrong

Agent mode is available on Copilot Pro, Business, and Enterprise. Not available on the free tier.

Good Tasks for Agent Mode

  • Well-defined, bounded features: “add email validation to the signup form with error messages”
  • Repetitive pattern application: “add logging to every API endpoint in this service”
  • Test coverage: “write unit tests for all functions in auth.ts that currently have no tests”
  • Migrations: “migrate from Moment.js to date-fns across the whole project”

Limitations & What to Watch For

  • Scope creep — agent mode may make broader changes than intended if the task description is vague. Review diffs carefully before accepting.
  • Wrong assumptions — if the codebase has unusual patterns, Copilot may make changes that technically work but don't follow your conventions.
  • Terminal permissions — you will be asked to approve terminal command execution before Copilot runs commands; you can review and block specific commands.
  • Doesn't understand external state — Copilot only sees what's in the filesystem. It can't know about database state, running services, or environment-specific configurations.

Checklist: Do You Understand This?

  • Agent mode is autonomous — plans tasks, edits files, runs commands, iterates on errors without per-step approval
  • Available in VS Code on Pro/Business/Enterprise plans (not free tier)
  • Enable via the mode selector in the Chat panel — switch from “Ask” to “Agent”
  • Best tasks: bounded features, repetitive patterns, test writing, library migrations
  • Watch for: scope creep, non-standard convention violations, terminal command execution (requires approval)

Page built: 01 Jun 2026