Skip to content

Commit dccf498

Browse files
authored
Merge pull request #10751 from MicrosoftDocs/main638827527100476279sync_temp
Repo sync for protected branch
2 parents d3e3dbb + e49aded commit dccf498

36 files changed

+432
-9
lines changed

docs/ide/copilot-agent-mode.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
title: 'Use agent mode (Preview)'
3+
description: Use GitHub Copilot Agent to iterate on code in Visual Studio by making code edits, running commands, and reading error/build context.
4+
ms.date: 5/13/2025
5+
ms.topic: get-started
6+
author: anandmeg
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+
# Use Copilot agent mode in Visual Studio (Preview)
14+
15+
With GitHub Copilot's agent mode in Visual Studio, you can use natural language to specify a high-level task. AI will then autonomously reason through the request, plan the work needed, and apply the changes to your codebase. Agent mode combines 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 key difference from Copilot Chat is that agent mode can:
18+
19+
* Run commands and builds to interpret the environment or execute a task (for example, database migrations, dotnet restore, etc.).
20+
* Iterate on errors, failed builds, or unit test results until it either requires additional input or considers the task complete.
21+
22+
## Prerequisites
23+
24+
+ [Visual Studio 2022 version 17.14](/visualstudio/releases/2022/release-history) or later.
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+
## Get started with agent mode
29+
30+
To get started with Copilot agent mode in Visual Studio, enable the feature in **Tools** > **Options** > **GitHub** > **Coplit** > **Copilot Chat** > **Enable agent mode in the chat pane**.
31+
32+
## Use agent mode
33+
34+
In agent mode, Copilot operates autonomously and determines the relevant context for your prompt.
35+
36+
Follow these steps to get started:
37+
38+
1. Ensure agent mode is enabled by selecting **Enable agent mode in the chat pane** in **Tools** > **Options** > **GitHub** > **Copilot** > **Copilot Chat**.
39+
40+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-setting-updated.png" alt-text="Screenshot that shows the enable agent mode setting in Options." lightbox="media/vs-2022/copilot-agent/copilot-agent-setting-updated.png":::
41+
42+
2. Open the Copilot Chat window, select **Ask** to expand the mode dropdown, and then select **Agent**.
43+
44+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-dropdown.png" alt-text="Screenshot that shows Copilot agent mode selector." lightbox="media/vs-2022/copilot-agent/copilot-agent-dropdown.png":::
45+
46+
3. Enter your prompt for making edits in the chat input field and select **Send** or press **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 the files to edit autonomously.
47+
48+
4. Agent mode might invoke multiple tools to accomplish different tasks. Optionally, select the **Tools** icon to configure which additional tools can be used for responding to your request.
49+
50+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-tools.png" alt-text="Screenshot that shows additional tools used by agent mode." lightbox="media/vs-2022/copilot-agent/copilot-agent-tools.png":::
51+
52+
5. Confirm tool invocations and terminal commands. Before running a terminal command or a 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.
53+
54+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-command-approval.png" alt-text="Screenshot that shows agent command approval." lightbox="media/vs-2022/copilot-agent/copilot-agent-command-approval.png":::
55+
56+
6. Copilot detects issues and problems in code edits and terminal commands, and then iterates and performs 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.
57+
58+
7. As Copilot processes your request, notice that Copilot streams the suggested code edits directly in the editor. Review the suggested edits and either keep or discard the suggested edits as a whole in **Total Changes** in the chat window, or individually by clicking on a file and reviewing the code diffs presented in the editor.
59+
60+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-keep-undo.png" alt-text="Screenshot that shows the list of suggested edits." lightbox="media/vs-2022/copilot-agent/copilot-agent-keep-undo.png":::
61+
62+
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.
63+
64+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-stepwise-edits.png" alt-text="Screenshot that shows accessing individual edit diffs with Copilot agent." lightbox="media/vs-2022/copilot-agent/copilot-agent-stepwise-edits.png":::
65+
66+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-cumulative-edits.png" alt-text="Screenshot that shows accessing cumulative edit diffs with Copilot agent." lightbox="media/vs-2022/copilot-agent/copilot-agent-cumulative-edits.png":::
67+
68+
9. Continue to iterate on the code changes to refine the edits or implement additional features.
69+
70+
## Agent mode tools
71+
72+
Agent mode can use the following tools:
73+
74+
* Built-in tools
75+
* [MCP tools](mcp-servers.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 window to view and manage the tools that are available in agent mode.
78+
79+
:::image type="content" source="media/vs-2022/copilot-agent-mcp/copilot-agent-partial-tools.png" alt-text="Screenshot that shows Copilot agent tool selector." lightbox="media/vs-2022/copilot-agent-mcp/copilot-agent-partial-tools.png":::
80+
81+
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.
82+
83+
Additional tools added by running MCP servers are not automatically enabled, they are unchecked by default and must be checked to be activated.
84+
85+
## Manage tool approvals
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+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-command-approval.png" alt-text="Screenshot that shows tool confirmation request." lightbox="media/vs-2022/copilot-agent/copilot-agent-command-approval.png":::
90+
91+
In the chat window, after a tool invocation, use the **Allow** dropdown options to automatically confirm the specific tool for the current session, solution, or all future invocations.
92+
93+
You can reset tool confirmation selections in **Tools** > **Options** > **GitHub** > **Copilot** > **Tools**.
94+
95+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-tool-config.png" alt-text="Screenshot that shows tool confirmation options." lightbox="media/vs-2022/copilot-agent/copilot-agent-tool-config.png":::
96+
97+
<!-- TODO: Define what "Reset solution setting does -->
98+
99+
## Accept or discard edits
100+
101+
Copilot lists the files that were edited in the list of **Total Changes** in the Chat window.
102+
103+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-keep-undo.png" alt-text="Screenshot that shows the Total Changes list." lightbox="media/vs-2022/copilot-agent/copilot-agent-keep-undo.png":::
104+
105+
Click on each file to review changes individually, where you can **Keep** or **Undo** edits made to each chunk of code.
106+
107+
Alternatively, in the **Total Changes** list, select **Keep** or **Undo** for all edits made since the last time you clicked **Keep** or **Undo**.
108+
109+
## Revert edits
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, when you want to use another implementation strategy or if Copilot starts walking down the wrong path when generating edits. To do so, select **Restore** next to the checkpoint prior to the prompt that included changes you didn't want.
112+
113+
:::image type="content" source="media/vs-2022/copilot-agent/copilot-agent-checkpoint.png" alt-text="Screenshot that shows reverting edits." lightbox="media/vs-2022/copilot-agent/copilot-agent-checkpoint.png":::
114+
115+
Currently, Visual Studio Copilot Agent doesn't support stepwise undo/redo.
116+
117+
## Interrupt an agent mode request
118+
119+
To interrupt an ongoing request, you can cancel it.
120+
This stops all running tools and terminal commands.
121+
122+
To stop a build, select **Build** in the top toolbar, and then select **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+
- Make sure you're using Visual Studio 17.14 or later: check the version at **Help** > **About Visual Studio**. If you're not using version 17.14 or later, launch the Visual Studio Installer and update your build.
130+
- Make sure you've selected the **Enable agent mode in the chat pane** setting in **Tools** > **Options** > **GitHub** > **Copilot Chat**.
131+
- Try restarting Visual Studio.
132+
133+
#### When should I use Ask mode vs. Agent mode?
134+
135+
- Ask mode is excellent when you want 100% confidence that no code edits are made unless you explicitly select **Apply** or copy and paste the code yourself.
136+
- Agent mode can handle the same conceptual questions, generate code examples without applying them, along with its agent capabilities of editing code.
137+
- If you are looking to use MCP capabilities, you must have agent mode selected.
138+
139+
#### What happened to Copilot Edits in Visual Studio?
140+
141+
- We perceive agent mode to be an evolution of Edits, with greater ability to iterate on errors, use tools, and automatically apply code changes.
142+
- For the initial releases of Visual Studio 2022 version 17.14, Edits mode is still available if you uncheck the **Enable agent mode in the chat pane** setting in **Tools** > **Options** > **GitHub** > **Copilot** > **Copilot Chat**.
143+
144+
#### As an administrator, how do I control use of agent mode for Visual Studio users?
145+
146+
Agent mode in Visual Studio is governed by the **Editor preview features** flag in the GitHub Copilot dashboard for administrators.
147+
If the administrator turns off this setting, users under that subscription won’t be able to use agent mode in Visual Studio.
148+
149+
For more information, see [managing policies and features 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).
150+
151+
## Related content
152+
153+
- [GitHub Copilot Edits](copilot-edits.md)
154+
- [GitHub Copilot Free](https://aka.ms/ghdocscopilotfreepage)

docs/ide/copilot-free-plan.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'GitHub Copilot Free in Visual Studio'
33
description: Use GitHub Copilot Completions, Chat, and Edits for free in Visual Studio.
4-
ms.date: 1/23/2025
4+
ms.date: 5/13/2025
55
ms.topic: overview
66
author: anandmeg
77
ms.author: meghaanand
@@ -22,7 +22,8 @@ To get started with Copilot Free in Visual Studio, you need:
2222

2323
## Get started with Copilot Free in Visual Studio
2424

25-
Set up Copilot Free using Visual Studio as follows:
25+
With Visual Studio version 17.14, you can [activate Copilot Free at first launch](work-with-github-accounts.md#add-a-github-account-at-first-launch).
26+
You can set up Copilot Free using Visual Studio later as follows:
2627

2728
1. Use **Ctrl+\\** to open the chat window in Visual Studio. You can also select the **GitHub Copilot** badge in the upper-right corner of the IDE, and then select **Open Chat Window** from the dropdown to open chat.
2829
1. Select **Sign up for Copilot Free**.
@@ -71,7 +72,7 @@ When you reach usage limits for Copilot Free, you can wait for them to reset at
7172

7273
#### Who can access Copilot Free?
7374

74-
Copilot Free is not available if you have an EMU account, access to a Copilot seat through an organization, an existing Copilot Pro subscription or trial, or free access to Copilot Pro as a student, teacher, or open-source maintainer.
75+
Copilot Free is not available if you have an EMU account, access to a Copilot license through an organization, an existing Copilot Pro subscription or trial, or free access to Copilot Pro as a student, teacher, or open-source maintainer.
7576
For the latest information, see [About GitHub Copilot Free](https://aka.ms/ghdocscopilotfreepage).
7677

7778
#### Can I turn off completions to save them for later?
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: Copilot Next Edit Suggestions
3+
description: Use Copilot Next Edit Suggestions (NES) to predict where you'll want to make your next edit and what that edit should be, based on your recent code edits.
4+
ms.date: 5/13/2025
5+
ms.topic: get-started
6+
author: anandmeg
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+
# Copilot Next Edit Suggestions
14+
15+
Next edit suggestions use recent edits you make to anticipate the next edit you might want to make, and the location of that edit. With this new ability, GitHub Copilot suggests revisions to your code, comments, tests, and more.
16+
17+
Inline completions are great at autocompleting a section of code. Copilot NES helps you stay in the logical edit flow, suggesting changes relevant to your current work, and you can simply `Tab` to quickly navigate and accept Copilot's suggestions. Suggestions may span a single symbol, an entire line, or multiple lines, depending on the scope of the potential change.
18+
19+
## Prerequisites
20+
21+
To get started, you need:
22+
+ Visual Studio 2022 [version 17.14](/visualstudio/releases/2022/release-history) or later
23+
+ [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/>
24+
<sup>**</sup> You can use [GitHub Copilot for Free](copilot-free-plan.md). Sign up and leverage AI to code faster and more efficiently.
25+
26+
## Get started with NES
27+
28+
To get started with Copilot NES, enable the feature in **Tools > Options > GitHub > Copilot > Copilot Completions > Enable Next Edit Suggestions**.
29+
30+
## Use next edit suggestions
31+
32+
To start getting suggestions from NES, start coding. When Copilot suggests code edits, you can navigate to it with the `Tab` key, and then accept it with the `Tab` key again. You save time by quickly jumping to the next relevant edit, without needing to manually search through files or references yourself. An arrow in the gutter indicates whether an edit suggestion is available.
33+
34+
:::image type="content" source="media/vs-2022/next-edit-suggestions/next-edit-suggestions-arrows.png" alt-text="Screenshot that shows arrows in gutter indicating next edit suggestions.":::
35+
36+
An arrow in the gutter indicates if there is an edit suggestion available. Click the arrow to explore the edit suggestion menu, which includes keyboard shortcuts.
37+
38+
:::image type="content" source="media/vs-2022/next-edit-suggestions/next-edits-menu.png" alt-text="Screenshot that shows the next edits menu." lightbox="media/vs-2022/next-edit-suggestions/next-edits-menu.png":::
39+
40+
If an edit suggestion is below the current editor view, the arrow points down instead of right. Scroll past an edit suggestion and the arrow hints the location of the next edit suggestion, pointing up or down based on where you're in the file.
41+
42+
:::image type="content" source="media/vs-2022/next-edit-suggestions/arrow-upward.png" alt-text="Screenshot that shows arrow pointing upward to indicate next edit suggestion location in file.":::
43+
44+
## Use cases for Next Edit Suggestions
45+
46+
NES is helpful in various scenarios, not only making obvious repetitive changes, but also logical changes. Here are some examples:
47+
48+
### Catch and correct mistakes
49+
50+
- NES helps with mistakes like typos, for example, if you wrote `bol` instead of `bool`.
51+
52+
:::image type="content" source="media/vs-2022/next-edit-suggestions/fix-typo.png" alt-text="Screenshot that shows NES suggesting typo correction.":::
53+
54+
- Copilot can also help with more challenging mistakes in logic, like an inverted ternary expression or a comparison that should use `||` instead of `&&`.
55+
56+
:::image type="content" source="media/vs-2022/next-edit-suggestions/ternary-expression.png" alt-text="Screenshot that shows NES suggesting the correction for an expression.":::
57+
58+
### Change in intent
59+
60+
NES suggests changes to the rest of your code that match a change in intent. For example, when refactoring a `Point` class to `Point3D`.
61+
62+
:::image type="content" source="media/vs-2022/next-edit-suggestions/change-in-intent-point-example.gif" alt-text="Animated screenshot that shows NES suggestions for change in intent updates." lightbox="media/vs-2022/next-edit-suggestions/change-in-intent-point-example.gif":::
63+
64+
### Update code syntax
65+
66+
NES helps with repetitive changes, such as updating code syntax to modern C++ using the Standard Library (STL). For example, when updating all `printf()` to `std::cout`, also update other syntax such as `fgets()`.
67+
68+
:::image type="content" source="media/vs-2022/next-edit-suggestions/update-code-syntax.gif" alt-text="Animated screenshot that shows NES suggesting code syntax updates" lightbox="media/vs-2022/next-edit-suggestions/update-code-syntax.gif":::
69+
70+
### Refactor
71+
72+
- Rename a variable once in a file, and NES will suggest updating it throughout the file. If you introduce a new name or naming pattern, Copilot suggests updates to subsequent code to match.
73+
74+
:::image type="content" source="media/vs-2022/next-edit-suggestions/rename-variable-edits.png" alt-text="Screenshot that shows NES suggesting edits when a variable is renamed.":::
75+
76+
- Match code style. After you paste some code, NES suggests adjustments to match it with the style of the surrounding code.
77+
78+
## Related content
79+
80+
- [GitHub Copilot Completions](visual-studio-github-copilot-extension.md)
81+
- [GitHub Copilot Chat](visual-studio-github-copilot-chat.md)
82+
- [GitHub Copilot Trust Center](https://resources.github.com/copilot-trust-center/)

0 commit comments

Comments
 (0)