Sub topic 8
Choose between Ask, Edit, and Agent modes
Copilot Chat in VS Code has three modes. They differ in how much Copilot can change on its own. This chapter explains what each mode does and how to pick one for a task. It also covers the failure modes of each.
This chapter assumes the following:
- The Copilot extension is installed and you are signed in.
- You can open the Chat view and type a prompt.
- You know how to use source control to review and revert changes.
Menu names and some behaviors change between VS Code releases. If your interface differs, check the mode picker in your own Chat view.
The three modes
You choose a mode with the mode picker, a dropdown in the Chat input area. The mode applies to the next request you send. You can switch it between requests in the same conversation.
| Mode | What Copilot can do | Who chooses the files | Changes your files? |
|---|---|---|---|
| Ask | Answer questions, explain code, suggest snippets | You, through context | No |
| Edit | Propose edits across several files in one pass | You, by adding files to the working set | Yes, as changes you review |
| Agent | Plan steps, find files, edit, run commands, react to errors | Copilot | Yes, and it can run commands |
Think of the modes as a ladder of autonomy. Ask gives you information. Edit applies a change you have scoped. Agent works toward a goal and decides the steps itself.
Ask mode
Ask mode is for understanding. Copilot reads the context you give it and replies in the chat. It does not write to your files. Code blocks in the answer are suggestions, and you decide whether to copy or insert them.
Use Ask mode when you want to:
- Understand unfamiliar code, such as a function, a module, or an error message.
- Compare approaches before you commit to one.
- Learn how a library or language feature works.
- Get a snippet to adapt yourself.
A typical Ask prompt attaches a file with the #file reference so the answer is based on its contents:
Explain what #file:utils.ts does and suggest one way to simplify it.Ask mode is the safest of the three because nothing can change without you. The risk is quality. If you give it no context, it answers from general knowledge and can describe code that does not match your project. Attach the relevant files or select the code first. The next chapter covers context in more detail.
Edit mode
Edit mode is for changes that you have already scoped. You add files to the working set, which is the list of files Copilot is allowed to modify. You then describe the change. Copilot returns edits to those files, and you review each one.
Edit mode suits tasks like these:
- Renaming a concept across five known files.
- Adding a parameter to a function and updating its callers.
- Converting a set of files from one pattern to another.
- Adding tests to a file you name.
An example prompt:
Add an optional `timeoutMs` parameter to fetchUser in api.ts. Update the two callers in profile.ts and settings.ts to pass the value from config.For this prompt, add api.ts, profile.ts, and settings.ts to the working set first.
The edits appear in the editor as a diff, with controls to keep or undo each change. Nothing is final until you accept it. Read each hunk the way you would read a pull request from a colleague.
Edit mode has two common failure modes:
- The working set is too small. Copilot cannot edit a file you did not include, so a change that needs a fourth file comes back incomplete. The code may then fail to compile, and Copilot does not run it to find out.
- The working set is too large. Many files dilute the request, and you have more to review. Include only what the change touches.
Edit mode does not run your code. It does not know whether tests pass after its edits. You run them.
Agent mode
Agent mode is for goals, not single edits. You describe an outcome, and Copilot works in a loop. It searches the workspace to find relevant files, edits them, runs commands, reads the output, and tries again if something fails. It can also use tools, such as the terminal, workspace search, and tools added by extensions or MCP servers.
An example prompt:
Add a /health endpoint to the Express server. Add a test for it, run the test suite, and fix any failures.Here you did not name the files. Copilot finds the server entry point, edits it, creates a test, runs the tests, and reacts to the result.
Agent mode is a good fit when:
- The task spans several steps, such as edit, run, and fix.
- You do not know in advance which files are involved.
- Verification matters, for example compile errors or failing tests that Copilot can read.
- The work is repetitive and well defined.
How Agent mode stays under your control
Agent mode asks for confirmation before it runs terminal commands and certain tool actions. You can allow or skip each one. Read the command before you approve it. Some versions let you remember an approval, but that makes later commands run without a prompt, so use it only for commands you trust.
You can also control which tools the agent may use. The chat input has a tool picker where you turn tools on or off. Disabling tools you do not need reduces both risk and noise.
Failure modes
- Scope creep. The agent may touch files you did not expect while fixing a failure. Check the full list of changed files, not only the one you care about.
- Loops. If a test keeps failing, the agent can try variations that never converge. Stop the request, read the error yourself, and give more specific guidance.
- Vague goals. A prompt like "improve this project" invites arbitrary changes. State what done looks like, such as "all tests pass" or "no TypeScript errors."
- Policy. Organizations can disable Agent mode, or restrict tools, for their members. If the option is missing from the picker, check your organization settings and your VS Code version.
Choosing a mode
Start with how much you already know and how much you want Copilot to decide.
Some tasks combine modes, and switching during a task is normal. For example:
- Use Ask to understand how authentication works in the project.
- Use Edit to make a small, scoped change to the token handling.
- Use Agent to run the test suite and fix the failures that result.
Decision criteria
| Question | If yes | If no |
|---|---|---|
| Do you only need an explanation? | Ask | Edit or Agent |
| Can you list every file that changes? | Edit | Agent |
| Does the task need running tests or commands? | Agent | Edit |
| Is the change risky or hard to undo? | Prefer Ask or Edit, on a branch | Agent is acceptable |
| Do you want to review every step? | Ask or Edit | Agent |
A useful rule is to use the least autonomous mode that can finish the task. Edit mode shows you everything it does. Agent mode saves effort when the task has many steps, but it costs you review time at the end.
Modes and custom instructions
All three modes can read repository custom instructions, so conventions apply no matter which mode you use. A file saved as .github/copilot-instructions.md might look like this:
# Copilot instructions
- Use TypeScript with strict typing; avoid `any`.
- Write unit tests with Vitest.
- Prefer named exports over default exports.This matters most in Agent mode. When the agent creates a new test file on its own, these instructions are why it uses Vitest rather than another framework. Without them, you would have to repeat the convention in each prompt.
Common mistakes
- Asking in Edit or Agent mode when you only want information. The request may change files. Switch to Ask.
- Expecting Ask mode to change code. It only replies. If you want edits, switch to Edit or Agent.
- Forgetting the working set in Edit mode. If edits are missing, check which files you added.
- Approving every terminal command without reading it. Treat each approval as running a command yourself.
- Accepting a large diff in one click. Review changes file by file, then run the tests.
- Starting Agent mode with uncommitted work. Commit or stash first so you can compare and revert.
Practice
Exercise
You want to rename a function getUser to fetchUser in three files you already know: api.ts, profile.ts, and settings.ts. You do not need to run any commands. Which mode fits best, and what must you do before sending the prompt?
Show answer
Edit mode fits best, because you know the files and no commands are needed. Before sending the prompt, add api.ts, profile.ts, and settings.ts to the working set so Copilot is allowed to modify them. Then review each proposed change before you keep it.
Exercise
You ask Agent mode to "fix the failing tests." It changes eight files, and one of them is a configuration file you did not expect. List two things you should do before accepting the result.
Show answer
Check the full list of changed files and read the diff for the unexpected configuration file, and keep or revert it deliberately. Run the test suite yourself to confirm the tests pass for the right reasons. Working on a clean Git branch makes both steps easier, because you can discard the whole change if needed.
Exercise
A teammate says they have no Agent option in the mode picker, although you do. Name two likely causes.
Show answer
Their organization may have disabled Agent mode through a Copilot policy. Their VS Code or Copilot extension version may also be too old to include it. Updating both, then checking the organization's Copilot settings, are the first steps.