Sub topic 2
Ask, edit, and agent modes compared
This chapter assumes you can work in VS Code, read a Git diff, and run build or test commands from a terminal. It also assumes you have used a chat-based AI coding assistant before. The goal is to help you pick the right chat mode for a task before you start typing.
Three modes, three levels of autonomy
Most editors with AI chat offer a mode switcher near the chat input. In VS Code with GitHub Copilot, the three modes are ask, edit, and agent. Names and exact behavior vary between editors and versions, so check your editor's current documentation.
- Ask mode answers questions. It can read code you attach or that is in the open editor, and it replies in chat. It does not change files.
- Edit mode changes files you choose. You pick the files that are in scope, describe the change, and the assistant proposes edits to those files only. You decide what to do with each edit.
- Agent mode takes a goal and works toward it in several steps. It searches the workspace, reads files, edits several files, runs terminal commands, and reads the results. It keeps going until it believes the task is done or it needs your input.
The main difference is who decides what happens next. In ask and edit modes, you do. In agent mode, the assistant does, within the limits of the tools and approvals you have configured.
Comparison
| Row | Ask | Edit | Agent |
|---|---|---|---|
| Changes files | No | Yes, only files you add | Yes, any file it decides to touch |
| Runs terminal commands | No | No | Yes, after your confirmation by default |
| Finds files on its own | Limited | No | Yes |
| Checks its own work | No | No | Can run tests and read errors |
| Typical cost and time | Low | Low to medium | Higher, since it makes many model calls |
| Risk of unwanted changes | None | Small, limited to chosen files | Larger, needs review |
Choosing a mode
Start with the least powerful mode that can finish the job.
- Use ask when you want to understand something: how a function works, why a test fails, what a library option does. Nothing in your project changes.
- Use edit when you know exactly which files change and what the change is. Examples are renaming a parameter across two files or adding a docstring. You keep tight control.
- Use agent when the work spans files you have not identified, or needs a run-and-fix cycle. Examples are adding a feature with tests, or fixing a failing build where the cause is unknown.
Common errors
- Using agent mode for a one-line change. The agent may search, read several files, and run the full test suite for something you could have edited yourself in seconds.
- Using edit mode for a task that needs discovery. If you do not know which files are involved, edit mode will miss them, because it only touches files you added.
- Expecting ask mode to apply changes. Ask can show a code suggestion, but you must copy or apply it yourself.
- Starting agent mode with uncommitted work. If the agent edits files you were already changing, separating your changes from its changes becomes difficult. Commit or stash first.
How the modes relate
The modes differ mainly in which tools the assistant may use. Ask has read-only context. Edit adds file modification. Agent adds search, terminal access, and any extra tools from MCP servers.
Exercises
Exercise
You need to rename the parameter userId to accountId in exactly two files that you already have open. Which mode fits best, and why?
Show answer
Edit mode. You know the files and the change, so limiting the assistant to those two files keeps the work fast, cheap, and easy to review. Agent mode would also work but adds searching and tool calls you do not need.
Exercise
A test fails in CI and you do not know which module is responsible. Describe a sequence of modes you could use.
Show answer
Start in ask mode, attaching the failing test output, to get hypotheses about the cause. Then switch to agent mode with a prompt that names the failing test, asks the agent to find the cause, fix it, and run the tests again. Commit your clean tree first so you can review the diff afterward.