Sub topic 13
Choosing a model for agent work
This chapter assumes you have used agent mode in VS Code, understand the agent loop (plan, call tools, observe results, repeat), and know how context and tool approval work from earlier chapters. It covers how to pick a model for agent tasks, what trade-offs to weigh, and what goes wrong when the choice doesn't fit the task.
Why the model matters more in agent mode
In ask mode, a weak answer costs you a few seconds of reading. In agent mode, the model makes many decisions in a row: which file to open, which command to run, whether a test failure means the code is wrong or the test is wrong. Each decision depends on the previous tool result. A small error early in the loop can compound into edits to the wrong files or a long chain of failed commands.
Three model properties matter most for this work:
- Tool-calling reliability. The model must produce well-formed tool calls with correct arguments, such as a valid file path or a correctly quoted shell command. Models that are weak here produce failing tool calls and waste turns.
- Reasoning over multiple steps. The model must keep a plan, notice when an observation contradicts it, and revise.
- Context window and recall. The model must hold the task, instructions, file contents, and tool output in a limited window, and still use the details that matter.
Speed and cost matter too, because an agent run may involve dozens of model calls for one prompt.
Where the model picker lives
In VS Code with GitHub Copilot, the chat view has a model picker next to the input box. The list depends on your plan, your organization's policy, and the extensions you have installed. Some models may not appear for agent mode if they do not support tool calling. If a model you expect is missing, check these three things in order:
- Whether your Copilot plan or organization policy enables that model.
- Whether the model is offered for agent mode specifically, since some models are available only for ask.
- Whether your VS Code and extension versions are current. Newer models often require an update.
Some setups also let you bring your own API key for a provider. In that case you pay the provider directly, and the provider's data handling terms apply. Treat that as a safety decision as well as a model decision (see the safety chapter).
Many tools also offer an automatic option that picks a model for you. This is convenient, but it makes runs less repeatable, because the same prompt may go to different models on different days. When you are debugging odd agent behavior, pin a specific model first.
The main trade-offs
No model wins on every dimension. The table below describes typical categories rather than specific products, because product names and rankings change often.
| Category | Strengths | Weaknesses | Good for |
|---|---|---|---|
| Fast, small models | Low latency, low cost | Lose the plan on long tasks, make more tool-call mistakes | Renames, small edits, boilerplate, single-file changes |
| General-purpose large models | Solid reasoning and tool use at moderate speed | Slower and costlier than small models | Most day-to-day agent tasks |
| Reasoning-focused models | Better at debugging, design decisions, and ambiguous requirements | Slow, expensive, sometimes over-think simple tasks | Hard bugs, cross-file refactors, unfamiliar codebases |
Larger context windows help when the agent must read many files. They do not guarantee good recall. A model can have a very large window and still overlook a detail buried in the middle of a long conversation. Keeping context focused (see the context chapter) is usually more effective than relying on a bigger window.
Premium requests and quotas
Some plans count requests to certain models against a monthly allowance, and a model may carry a multiplier, so one prompt counts as several requests. In agent mode, one user prompt can trigger many internal model calls. Whether those calls count once or many times depends on your plan's billing rules, so check the current documentation for your plan before assuming. If you hit a quota mid-task, the run may stop or fall back to another model. Look at which model is selected before you resume.
A decision process
Rather than memorizing a ranking, decide using the task's properties.
- How many files will change? One file favors a fast model. Many files favor a stronger one.
- How clear is the goal? A precise prompt with acceptance criteria works on a cheaper model. A vague goal ("find out why checkout is slow") needs stronger reasoning.
- How costly is a mistake? Changes to build configuration, migrations, or authentication code justify a stronger model and closer review.
- Is there a fast verification loop? If
npm testruns in seconds and covers the change, the agent can correct a weaker model's errors cheaply. Without tests, the model's judgment carries more weight. - How long will the session run? Long sessions fill the context window. Consider starting a new chat with a summary instead of switching to a bigger model.
A worked comparison
Take the task prompt from the earlier prompting chapter:
Add input validation to the createUser function in src/users.ts.
Reject empty names and malformed email addresses with a clear error.
Add unit tests for both cases next to the existing tests, then run `npm test` and fix any failures.
Do not change the public function signature.This prompt names the file, the acceptance criteria, a verification step, and a constraint. A fast model handles it well, because the work is local and npm test catches mistakes. Starting with a fast model costs little.
Now change the task: "Users sometimes receive two welcome emails. Find the cause and fix it." The cause could be in a queue consumer, a retry policy, or a webhook handler. The agent must form hypotheses, read across modules, and test them. A fast model may pick the first plausible cause and "fix" it without evidence. A reasoning model is more likely to compare hypotheses. Here the extra cost buys fewer wasted loops.
You can also split the work. Use a stronger model to produce a plan or diagnosis, review it yourself, then switch to a faster model to carry out the mechanical edits. When you switch models in the middle of a chat, the new model reads the existing conversation, so check that earlier tool output and decisions are still visible and correct.
Signs that the model is the problem
Not every bad run is a model problem. Bad prompts, missing context, and missing instructions cause many of the same symptoms. Try fixing those first. These signs point toward the model:
- Malformed or repeated tool calls. The agent calls a tool with a wrong path, or repeats the same failing command without changing it.
- Plan drift. Midway through, the agent stops working toward the original goal or forgets a constraint such as "do not change the public function signature."
- Fabricated results. The agent states that tests passed without running them, or cites a function that does not exist.
- Shallow fixes. The agent suppresses an error, such as by editing a test to match broken behavior, instead of finding the cause.
- Ignoring instructions. The agent breaks conventions from your instructions file even though the file is loaded. Smaller models follow long instruction lists less consistently.
When you see these, compare against the other causes in this order: check the prompt, check the attached context, check the instructions file, and only then change the model. Change one variable at a time, so you know what fixed the problem.
Models and other IDEs
JetBrains IDEs, Cursor, and similar editors all expose a model choice, but the details differ: which models are listed, whether you can add your own keys, whether an automatic mode exists, and how usage is billed. The same decision process applies everywhere. Also check whether the model setting applies per chat, per mode, or globally, because that affects whether a change carries over to your next conversation.
Practical defaults
- Start with a general-purpose model for agent mode unless you have a reason not to.
- Drop to a fast model for narrow, well-specified edits that have tests.
- Move up to a reasoning model for debugging and cross-cutting changes.
- Pin the model when diagnosing problems. Use automatic selection when you care more about convenience.
- Re-evaluate when your tool announces new models, and run one of your own recent tasks as a test before changing your default.
Exercise
You ask the agent to rename a helper function used in three files, and a test suite finishes in ten seconds. A teammate suggests using the most powerful reasoning model "to be safe." What would you choose, and what evidence would make you change your mind?
Show answer
Start with a fast or general-purpose model. The task is local and well specified, and the fast test suite catches mistakes cheaply, so the extra cost and latency of a reasoning model buy little. Change the choice if you see signs of a model problem after checking the prompt and context, such as malformed tool calls, repeated failing commands, or edits that ignore the stated constraint. Then move up one tier and retry.
Exercise
An agent run on a vague bug report keeps editing a test to match the current behavior instead of finding the cause. List the order in which you would investigate, and say when you would switch models.
Show answer
First check the prompt: state that tests must not be changed to fit the bug and describe the expected behavior. Second, check the attached context to confirm the relevant source files are included. Third, check the instructions file for a rule about not weakening tests. If the agent still applies shallow fixes after those changes, switch to a reasoning-focused model, changing only that one variable, and compare the result.