Introducing GitHub Copilot agent mode (preview)

To Nha Notes | Feb. 27, 2025, 8:44 a.m.

February 24, 2025 by Isidor Nikolic

Copilot agent mode is the next evolution in AI-assisted coding. Acting as an autonomous peer programmer, it performs multi-step coding tasks at your command — analyzing your codebase, reading relevant files, proposing file edits, and running terminal commands and tests. It responds to compile and lint errors, monitors terminal and test output, and auto-corrects in a loop until the task is completed. Available to all VS Code Insiders users today, and soon in VS Code Stable.

How to use Copilot agent mode

In VS Code Insiders, open the Copilot Edits view (Ctrl+Shift+Alt+I), select Agent from the mode dropdown, and enter your prompt.

Copilot agent mode can create apps from scratch, perform refactorings across multiple files, write and run tests, and migrate legacy code to modern frameworks. It can automatically generate documentation, integrate new libraries, or help answer questions about a complex codebase. Copilot agent mode helps you be super-productive by having an AI collaborator that understands the workspace. It can orchestrate your inner development flow while keeping you in control.

Copilot agent mode operates in a more autonomous and dynamic manner to achieve the desired outcome. To process a request, Copilot loops over the following steps and iterates multiple times as needed:

  • Determines the relevant context and files to edit autonomously.
  • Offers both code changes and terminal commands to complete the task. For example, Copilot might compile code, install packages, run tests, and more.
  • Monitors the correctness of code edits and terminal command output and iterates to remediate issues.

Copilot agent mode uses a set of tools to accomplish these tasks.

In an ideal world, you would just care about the final output of Copilot agent mode, but it can sometimes make mistakes and go off track. To easily intervene and undo in those situations, every tool invocation is transparently displayed in the UI, terminal tool requires approval, and we support rich undo capabilities - you can use the Undo Last Edit control in the view title bar to revert to the state before the last edit was applied. Instead of relying on one long, detailed prompt to yield a perfect solution, you should iterate with Copilot – the UI is built for iterations, giving you full control over the process ensuring the final result is better.

Copilot agent mode automatically finds the precise context and sets the working set of files by calling the right workspace tools. To more precisely guide Copilot, you can always explicitly reference context with #file, using drag and drop or by clicking on the Add Files button. For example, you can create a specifications.md file and add it as context to better control Copilot, or you can set custom instructions - so Copilot respects your coding guidelines or other preferences.

Keep in mind that because Copilot agent mode may send multiple requests per prompt, it won’t be as fast as regular edits mode and can quickly use up your free Copilot quota. For tasks that are well-defined and scoped, stick to edits mode. When you need multiple edits or more open-ended tasks, switch to agent mode.

How it works

Diagram showing the inner works of agent mode and how it interacts with context, LLM and tools

When you send a request to Copilot in agent mode, we make a prompt to the LLM you picked from the model dropdown. This prompt includes:

  • Your query
  • A summarized structure of the workspace (instead of the full codebase to preserve tokens)
  • Machine context (e.g. what OS you are using)
  • Tool description (optionally tool call result)

We define a set of tools for the LLM to call, each tool has its own capabilities that help Copilot get the job done. Using these tools Copilot can search the workspace, read the contents of files, run commands in the terminal, get compile or lint errors from the editor and apply proposed changes via a speculative decoder endpoint (performance improvements underway). The list of tools is ever-expanding, as we are experimenting what other tools could improve Copilot’s capabilities in agent mode.

References

https://code.visualstudio.com/blogs/2025/02/24/introducing-copilot-agent-mode