You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use Copilot Edits to start an AI-powered code editing session and iterate quickly on code changes across multiple files by using natural language. Copilot Edits applies the edits directly in the editor, where you can review them in-place, with the full context of the surrounding code. Copilot Edits brings the conversational flow of Copilot Chat and immediate feedback from Inline Chat together in one experience.
13
+
Use Copilot Edits to start an AI-powered code editing session and iterate quickly on code changes across multiple files by using natural language. Copilot Edits applies the edits directly in the editor, where you can review them in-place, with the full context of the surrounding code.
14
14
15
15
Copilot Edits can function in two modes:
16
16
17
17
*[*Edit mode*](#use-edit-mode): select which files to edit, provide the relevant context and prompt, and Copilot will suggest code edits.
18
18
*[*Agent mode*](#use-agent-mode-preview) (preview): let Copilot determine which files to edit and which commands to run. Copilot will autonomously use different [tools](#agent-mode-tools) to iterate and resolve issues to achieve the desired outcome.
19
19
20
+
> [!NOTE]
21
+
> Agent mode is currently in preview and we continue to improve the experience. Provide feedback and report issues in the [Copilot repository](https://github.com/microsoft/vscode-copilot-release/issues).
22
+
>
23
+
> To enable agent mode, set the `setting(github.copilot.chat.agent.enabled)` setting to `true`.
24
+
20
25
The following video demonstrates how to use Copilot Edits to extend a basic Express app, such as adding a new page, navigation bar, and theme switcher.
21
26
22
27
<videosrc="images/copilot-edits/copilot-edits-hero.mp4"title="Use Copilot Edits to modify an Express app"loopcontrolsmuted></video>
@@ -46,17 +51,19 @@ Because making code changes can be an iterative process, an *edit session* in Co
46
51
47
52
In edit mode, you select which files to edit and provide the relevant context and prompt. Copilot will suggest code edits based on your prompt.
48
53
49
-
1. Open the Copilot Edits view
54
+
1. Open the Copilot Edits view (`kb(workbench.action.chat.openEditSession)`)
50
55
51
56
1. Select **Edit** from the mode dropdown
52
57
58
+

59
+
53
60
1. Use **Add Files** to add files to the _working set_
54
61
55
62
The working set indicates which files in the workspace can be edited by Copilot Edits.
56
63
57
64
1. Enter a prompt to request code edits. Be specific and precise about the changes you want, and decompose larger tasks into smaller tasks.
58
65
59
-
Copilot Edits streams the edits in the editor. In the working set, edited files are marked in bold.
66
+
Copilot Edits streams the edits in the editor. In the working set, files that were edited by Copilot are marked in bold.
60
67
61
68
> [!TIP]
62
69
> Add more specific context by using chat variables like `#file` or `#sym` to reference files or symbols. Use `#codebase` to let Copilot collect relevant context from your entire workspace.
@@ -69,38 +76,45 @@ In edit mode, you select which files to edit and provide the relevant context an
69
76
70
77
## Use agent mode (preview)
71
78
72
-
In agent mode, Copilot Edits operates in a more autonomous and dynamic manner to achieve the desired outcome:
79
+
In agent mode, Copilot Edits 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:
73
80
74
81
* Creates a plan of action and decomposes the request into smaller tasks.
75
82
* Determines the relevant context and files to edit autonomously.
76
83
* Offers both code changes and terminal commands to complete the task. For example, Copilot might compile code, install packages, run tests, and more.
77
-
* Monitors correctness of code edits and terminal command output and iterates to remediate issues.
78
-
79
-
Copilot Edits agent mode uses a set of [_tools_](#agent-mode-tools) to accomplish these tasks. For example, to determine which files to edit, gather project context, run terminal commands, read terminal output, and more.
84
+
* Monitors the correctness of code edits and terminal command output and iterates to remediate issues.
80
85
81
-
To enable agent mode in Copilot Edits, set the `setting(github.copilot.chat.agent.enabled)` setting to `true`.
82
-
83
-
> [!NOTE]
84
-
> Agent mode is currently in preview. The experience might change, and you might encounter issues. Provide feedback and report issues in the [Copilot repository](https://github.com/microsoft/vscode-copilot-release/issues).
86
+
Copilot Edits agent mode uses a set of [_tools_](#agent-mode-tools) to accomplish these tasks. These tools can run in parallel to accomplish the requested task.
85
87
86
88
To use agent mode in Copilot Edits:
87
89
88
-
1. Open the Copilot Edits view
90
+
1. Enable agent mode in by setting the `setting(github.copilot.chat.agent.enabled)` setting to `true`.
91
+
92
+
1. Open the Copilot Edits view (`kb(workbench.action.chat.openEditSession)`)
89
93
90
94
1. Select **Agent** from the mode dropdown
91
95
96
+

97
+
92
98
1. Enter a prompt to request code edits.
93
99
94
-
In agent mode, Copilot Edits will determine the relevant context and files to edit autonomously.
100
+
You don't have to specify the working set. In agent mode, Copilot Edits determines the relevant context and files to edit autonomously.
101
+
102
+

95
103
96
104
Copilot Edits streams the edits in the editor and updates the working set. In addition, Copilot can suggest terminal commands to run.
97
105
98
106
1. Review the suggested code edits, and confirm if Copilot can run the proposed terminal commands
99
107
100
-
You have to confirm the commands to run because they might result in changes to your project.
108
+
As a user, you stay in control of the changes that are made to your project and can [review the generated edits](#accept-or-discard-edits) and need to confirm the terminal commands to run.
109
+
110
+

101
111
102
112
1. Copilot Edits detects issues and problems in code edits and terminal commands, and will iterate and perform additional actions to resolve them.
103
113
114
+

115
+
116
+
1. Continue to ask follow-up questions and iterate on the code changes that Copilot Edits provides.
117
+
104
118
## Manage the working set
105
119
106
120
The _working set_ is the set of files that you want Copilot Edits to work on for your edit session. Copilot Edits does not make changes outside the working set, except when suggesting to create a new file. When you use agent mode, Copilot autonomously determines which files to edit and adds them to the working set.
@@ -197,18 +211,22 @@ After moving a chat request to Copilot Edits, the chat request is removed from t
197
211
198
212
## Agent mode tools
199
213
200
-
To complete a request, Copilot Edits uses a set of _tools_ to accomplish the individual tasks. The following list gives an overview of the built-in tools:
214
+
To complete a request, Copilot Edits uses a set of _tools_ to accomplish the individual tasks. These tools can run in parallel to accomplish the requested task.
215
+
216
+
The following list gives an overview of the built-in tools:
217
+
218
+
*`search_codebase` - Search the workspace for relevant code or documentation
219
+
*`file_search` - Search for files by glob patterns (for example, "**/*.js")
220
+
*`grep_search` - Do a text search in files for exact strings or regex patterns
221
+
*`read_file` - Read the contents of a file
222
+
*`edit_file` - Edit a file in the workspace, changes can be [reviewed](#accept-or-discard-edits) like other edits
223
+
*`list_dir` - List the contents of a directory
224
+
*`run_in_terminal` - Run shell commands in a terminal (requires user confirmation)
225
+
*`get_terminal_output` - Get output from a previously run terminal command
226
+
*`get_errors` - Check for errors in code files and helps agent mode to self-correct code issues
227
+
*`get_changed_files` - Get diffs of file changes
201
228
202
-
* search_codebase - Search the workspace for relevant code or documentation
203
-
* file_search - Search for files by glob patterns (e.g., "**/*.js")
204
-
* grep_search - Do a text search in files for exact strings or regex patterns
205
-
* read_file - Read the contents of a file
206
-
* edit_file - Edit a file in the workspace
207
-
* list_dir - List the contents of a directory
208
-
* run_in_terminal - Run shell commands in a terminal
209
-
* get_terminal_output - Get output from a previously run terminal command
210
-
* get_errors - Check for errors in code files
211
-
* get_changed_files - Get diffs of file changes
229
+
Agent mode gives you a more autonomous AI-powered editing experience, however you maintain control over the generated edits and terminal commands that are run.
212
230
213
231
## Settings
214
232
@@ -280,11 +298,12 @@ You can drag and drop the Copilot Edits view into the Activity Bar to show it in
280
298
281
299
### Why would I use edit mode instead of agent mode?
282
300
283
-
Consider the following criteria
301
+
Consider the following criteria to choose between edit mode and agent mode:
284
302
285
303
***Edit scope**: you might use edit mode if your request involves only code edits and you know the precise scope and working set for the changes.
286
304
***Preview feature**: agent mode is still in preview and might not work for all scenarios.
287
-
***Response time**: agent mode involves more steps to process a request, so it might take longer to get a response. For example, to determine the relevant context and files to edit, determine the plan of action, and more.
305
+
***Duration**: agent mode involves multiple steps to process a request, so it might take longer to get a response. For example, to determine the relevant context and files to edit, determine the plan of action, and more.
306
+
***Non-deterministic**: agent mode evaluates the outcome of the generated edits and might iterate multiple times. As a result, agent mode can be more non-deterministic than edit mode.
288
307
***Request quota**: in agent mode, depending on the complexity of the task, one prompt might result in many requests to the backend.
0 commit comments