|
| 1 | +--- |
| 2 | +title: 'GitHub Copilot Agent (Preview)' |
| 3 | +description: GitHub Copilot Agent iterates on code in Visual Studio by making code edits, running commands, and reading error/build context. |
| 4 | +ms.date: 5/8/2025 |
| 5 | +ms.topic: overview |
| 6 | +author: aayim |
| 7 | +ms.author: meghaanand |
| 8 | +ms.manager: mijacobs |
| 9 | +ms.subservice: ai-tools |
| 10 | +ms.collection: ce-skilling-ai-copilot |
| 11 | +monikerRange: '>= vs-2022' |
| 12 | +--- |
| 13 | +# What is GitHub Copilot Agent? |
| 14 | + |
| 15 | +With GitHub Copilot's agent mode in Visual Studio, you can use natural language to specify a high-level task, and let AI autonomously reason about the request, plan the work needed, and apply the changes to your codebase. Agent mode uses a combination of code editing and tool invocation to accomplish the task you specified. As it processes your request, it monitors the outcome of edits and tools, and iterates to resolve any issues that arise. |
| 16 | + |
| 17 | +The critical difference compared to Copilot Chat is that the Agent mode can: |
| 18 | + |
| 19 | +1) Run commands and builds to interpret the environment or execute a task (i.e. database migration, dotnet restore, etc.) |
| 20 | +2) Iterate on errors, failed builds, unit test results until the agent requires more input or deems the task accomplished. |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | ++ [Visual Studio 2022 version 17.14](/visualstudio/releases/2022/release-history) and later have the Copilot Agent. |
| 24 | + + In the initial 17.14 release, you will need to set `Enable agent mode in the chat pane` in Tools > Options > GitHub > Copilot. |
| 25 | ++ [Sign in to Visual Studio using a GitHub account](work-with-github-accounts.md) with [Copilot access](https://docs.github.com/en/copilot/about-github-copilot/what-is-github-copilot#getting-access-to-copilot). <br/> |
| 26 | + + You can use [GitHub Copilot for Free](copilot-free-plan.md). Sign up and leverage AI to code faster and more efficiently. |
| 27 | + |
| 28 | +## How to use Copilot Agent |
| 29 | + |
| 30 | +In agent mode, Copilot operates autonomously and determines the relevant context for your prompt. |
| 31 | + |
| 32 | +Follow these steps to get started: |
| 33 | + |
| 34 | +1. Make sure that agent mode is enabled by clicking Tools > Options > GitHub > Copilot and the "Enable Agent mode in the chat pane". |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +2. Enable agent mode by opening the GitHub Copilot window, clicking the mode dropdown that says "Ask", then select "Agent". |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +3. Enter your prompt for making edits in the chat input field and select Send (Enter) to submit it. You can specify a high-level requirement, and you don't have to specify which files to work on. In agent mode, Copilot determines the relevant context and files to edit autonomously. |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +4. Agent mode might invoke multiple tools to accomplish different tasks. Optionally, select the Tools icon to configure which tools can be used for responding to your request. |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +5. Confirm tool invocations and terminal commands. Before running a terminal command or non-builtin tool, Copilot requests confirmation to continue. This is because tools might run locally on your machine and perform actions that modify files or data. |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +6. Copilot detects issues and problems in code edits and terminal commands and will iterate and perform additional actions to resolve them. For example, agent mode might run unit tests as a result of a code edit. If the tests fail, it uses the test outcome to resolve the issue. Copilot agent mode iterates multiple times to resolve issues and problems. |
| 55 | + |
| 56 | +7. As Copilot processes your request, notice that Copilot streams the suggested code edits directly in the editor. Review the suggested edits and accept or discard the suggested edits as a whole in the Total Changes section, or individually by clicking on a file and reviewing the code diffs presented in the editor. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +8. If you want to review individual code changes made by the agent, you can either review the specific change made at each step, or review the cumulative changes from the last time changes were kept or undone. |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +9. Continue to iterate on the code changes to refine the edits or implement additional features. |
| 67 | + |
| 68 | +## Agent mode tools |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +Agent mode can use the following tools: |
| 73 | + |
| 74 | +* Built-in tools |
| 75 | +* [MCP tools](mcp.md) |
| 76 | + |
| 77 | +You can view and manage the tools that can be used for responding to a request. Select the Tools icon in the Chat view to view and manage the tools that are available in agent mode. |
| 78 | + |
| 79 | +Based on the outcome of a tool, Copilot might invoke other tools to accomplish the overall request. For example, if a code edit results in syntax errors in the file, Copilot might explore another approach and suggest different code changes. |
| 80 | + |
| 81 | +Additional tools added by running MCP servers are not automatically enabled, they are unchecked by default and must be checked to be activated. |
| 82 | + |
| 83 | +## Manage tool approvals |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +When a tool is invoked, Copilot requests confirmation to run the tool. This is because tools might run locally on your machine and perform actions that modify files or data. |
| 88 | + |
| 89 | +In the Chat view, after a tool invocation, use the Allow button dropdown options to automatically confirm the specific tool for the current session, solution, or all future invocations. |
| 90 | + |
| 91 | +You can reset tool confirmation selections in Tools > Options > GitHub > Copilot > Tools. |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | +<!-- TODO: Define what "Reset solution setting does --> |
| 96 | + |
| 97 | +## Accept or discard edits |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +Copilot lists the files that were edited in the list of Total Changes files in the Chat view. |
| 102 | + |
| 103 | +Click on each file to review changes individually, where you can "Keep" or "Undo" edits made to each chunk of code. |
| 104 | + |
| 105 | +Alternatively, in the Total Changes dialogue, click "Keep" or "Undo" for all edits made since the last time you clicked Keep or Undo. |
| 106 | + |
| 107 | +## Revert edits |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +As you're sending requests to make edits to your code, you might want to roll back some of these changes, for example, because you want to use another implementation strategy or because Copilot starts walking down the wrong path when generating edits. |
| 112 | + |
| 113 | +You can achieve this by clicking "Restore" next to the checkpoint prior to the prompt that included changes you did not want. |
| 114 | + |
| 115 | +At time of writing, the Visual Studio Copilot Agent doesn't support stepwise undo/redo. |
| 116 | + |
| 117 | +## Interrupt an agent mode request |
| 118 | +To interrupt an ongoing request, you can cancel it. |
| 119 | + |
| 120 | +This stops all running tools and terminal commands. |
| 121 | + |
| 122 | +To stop a build, click `Build` in the top toolbar then click `Cancel` or use the `Ctrl + Break` keyboard shortcut. |
| 123 | + |
| 124 | +## Frequently Asked Questions |
| 125 | + |
| 126 | +### I don't see Ask and Agent mode in the GitHub Copilot Chat window. |
| 127 | + |
| 128 | +Take the following troubleshooting steps in the order specified: |
| 129 | + |
| 130 | +- Make sure you're using Visual Studio 17.14 or later: check by clicking `Help`, `About Visual Studio`. If you are not using version 17.14 or later, launch the Visual Studio Installer and update your build. |
| 131 | + |
| 132 | +- Make sure you have checked the `Enable agent mode in the chat pane` setting in `Tools > Options > GitHub > Copilot` |
| 133 | + |
| 134 | +- Try restarting Visual Studio. |
| 135 | + |
| 136 | +### When to use Ask and Agent modes? |
| 137 | + |
| 138 | +- Ask mode is excellent when you want 100% confidence that no code edits will be made without your explicit clicking of "Apply" or Copy and Pasting Code. |
| 139 | +- Otherwise, Agent mode can handle the same conceptual questions, generate code examples without applying them, along with its agent capabilities of editing code. |
| 140 | +- If you are looking to use MCP capabilities, you must have Agent mode selected. |
| 141 | + |
| 142 | +### What happened to Copilot Edits in Visual Studio? |
| 143 | + |
| 144 | +- We perceive Agent mode to an evolution of Edits, with greater ability to iterate on errors, use tools, and automatically apply code changes. |
| 145 | +- For the initial releases of Visual Studio 2022 version 17.14, Edits mode is still available if you uncheck the `Enable agent mode` setting in `Tools > Options`. |
| 146 | + |
| 147 | +### As an administrator, how do I control use of Agent mode for Visual Studio users? |
| 148 | + |
| 149 | +Agent mode in Visual Studio is governed by the "Editor preview features" flag in the GitHub Copilot dashboard for administrator. |
| 150 | + |
| 151 | +More information can be found in the GitHub documentation for [managing policies and feature for copilot in your enterprise](https://docs.github.com/en/enterprise-cloud@latest/copilot/managing-copilot/managing-copilot-for-your-enterprise/managing-policies-and-features-for-copilot-in-your-enterprise#editor-preview-features). |
| 152 | + |
| 153 | +## Related content |
| 154 | + |
| 155 | +- [Install and manage GitHub Copilot in Visual Studio](visual-studio-github-copilot-install-and-states.md) |
| 156 | +- [GitHub Copilot experience for Visual Studio](visual-studio-github-copilot-extension.md) |
| 157 | +- [GitHub Copilot Chat experience for Visual Studio](visual-studio-github-copilot-chat.md) |
| 158 | +- [About GitHub Copilot Free](https://aka.ms/ghdocscopilotfreepage) |
0 commit comments