Skip to content

GitHub Copilot Agent Mode

Local, synchronous agentic execution that reads files, runs code, checks output, and iterates to fix errors.

How It Works

Agent mode transforms Copilot from a suggestion engine into an autonomous executor. When you submit a prompt in agent mode, Copilot iterates across files and works through changes autonomously, proposes changes across multiple files, runs terminal commands, checks output, identifies errors, and loops back to fix them. It installs packages, runs tests, and migrates code without waiting for approval at each step.

Available in VS Code, and generally available in JetBrains, Eclipse, and Xcode.

Planning Mode

For complex tasks, Copilot generates a transparent plan outlining all steps before making changes. The plan supports structured reasoning and progress tracking.

Multi-File Editing

Copilot Edits allows specifying a set of files and describing changes in natural language. Copilot proposes inline edits across files iteratively.

Vision

Feed Copilot a screenshot, mockup, or image and it generates the UI code and implementation details.

Why It Works

Per GitHub's agent mode overview, the loop works because the language model reasons about the next step and issues tool calls to gather information or act — reading files, editing, running terminal commands. After each edit or command, agent mode inspects syntax errors, terminal output, test results, and build failures to decide how to course-correct. Deterministic feedback signals (compiler, linter, tests) anchor the loop — the more structured the signals, the faster it converges.

When This Backfires

Agent mode degrades when the feedback loop is weak or the task exceeds its context window:

Example

This example demonstrates agent mode's edit-run-fix loop. Open a project in VS Code with Copilot, switch to agent mode in the Copilot Chat panel, and submit a prompt like:

Migrate the user authentication module from express-session to JWT. Update all routes, add token refresh logic, and fix any test failures.

Copilot responds by reading the affected files, proposing changes across the codebase, running the test suite, and looping back on failures — without asking for step-by-step confirmation. A representative trace looks like:

[agent] Reading src/auth/session.ts, src/routes/user.ts, tests/auth.test.ts
[agent] Proposing changes to 4 files
[agent] Running: npm test
[agent] 2 tests failed — fixing token expiry handling in src/auth/jwt.ts
[agent] Running: npm test
[agent] All tests passing

For complex migrations, enable planning mode first — Copilot shows the full plan before touching any files. In VS Code, this is available via the #plan directive in the prompt:

#plan Migrate express-session to JWT across the auth module

Review the plan, approve, and then Copilot executes all steps.

Key Takeaways

  • Agent mode is the local, synchronous counterpart to the async coding agent
  • It iterates autonomously: edit, run, check, fix — without step-by-step approval
  • Planning mode adds transparency for complex multi-step tasks
  • Generally available across VS Code, JetBrains, Eclipse, and Xcode
Feedback