How to choose a model for coding is four questions, not a leaderboard rank: what you need the model to do, whether it can actually run a tool loop, who you trust with your code, and what your hardware can run. A benchmark answers none of them, and you never pick at random — each question rules out most of the field.
Same task, two models, same starting commit, shows why the ranking is the least useful part:
task: "Expired coupons are still accepted at checkout. Fix it and add a test."
model A 9 turns touched 2 files tests pass diff ready to merge
model B 22 turns touched 6 files tests pass renamed helpers nobody asked for
Both “solved” it. Model A is the better coding model here: it stayed in scope, used fewer tokens, and left less for you to review. No leaderboard column shows that.
1. What do you need it for?
“Coding model” is three different jobs, and a model built for one is wrong for another:
- An agentic coder reads files, runs commands and loops over a task until it is done. This is what Claude Code, Codex and OpenCode drive, and the rest of this page is about it.
- An autocomplete model finishes the line as you type, through fill-in-the-middle. Qwen2.5-Coder and StarCoder2 ship FIM variants for this; they are small and fast and do not run tools.
- An embedding model turns code into vectors for search and retrieval. Qwen3-Embedding and its kind never write code; they feed the agent’s context.
Pick the job first. A FIM model will not drive an agent, and a chat model makes slow, expensive autocomplete.
2. Can it actually run a tool loop?
This is the question leaderboards hide. A high SWE-bench score or a million-token context window does not mean a model can sustain a multi-step tool loop. It can have the window and still emit malformed tool calls, repeat the same call, edit the wrong file, or announce “done” with the tests still red. A large window on a model that cannot drive a loop is not a capability.
The signals that match agent work:
- Multi-turn tool use. The Berkeley Function Calling Leaderboard’s multi-turn rows and benchmarks like tau2 measure a model that called a tool, read the result, corrected itself, and called again. That predicts agent behavior far better than SWE-bench, which scores the model inside someone else’s harness.
- It knows when to stop. Good agent models finish, report and ask. Weaker ones loop, or wander into refactors you never requested.
- It holds instructions deep in a full context. “Don’t touch the tests” must still hold on turn forty. Accuracy drops as the context fills; Anthropic’s docs call the decline “context rot”, and the advertised maximum says little about it.
In Contenox’s own testing, models below roughly 3 to 4 billion parameters reliably fail multi-step tool use. They answer a question or make one edit; they do not sustain an agent. Size is a floor here, not a ranking.
3. Who do you trust with your code?
Origin and license decide where your code goes, and whether anyone is watching the model while it runs.
- Hosted frontier models — Anthropic’s Claude, OpenAI’s GPT and Codex, Google’s Gemini, all made and run in the US. Your code leaves your machine, so you trust the vendor’s retention and training terms and its stability. In return the model runs behind the lab’s safety layer: safety training, refusals and abuse monitoring you never see.
- Open-weight models you self-host — your code never leaves the machine. Qwen (Alibaba, Apache-2.0), DeepSeek (MIT), GLM (Z.ai) and Kimi (Moonshot) are China-origin but run fully offline; Mistral’s Devstral and Ministral are EU-made and Apache-2.0; gpt-oss (OpenAI, Apache-2.0), IBM’s Granite (Apache-2.0) and Microsoft’s Phi (MIT) are US open weights.
- Read the license before you ship. Open weights are not automatically free for commercial use. Codestral is license-restricted; GLM and Kimi carry custom terms. Apache-2.0 and MIT are the clean ones.
When you self-host, origin matters less for data and more for the license and the model’s own behavior — because your code stays put, but the safety net is gone. There is no frontier lab behind a model you run yourself, one instance or a fleet of agents. If the weights carry a trained-in pattern you cannot see — a backdoor, a poisoned behavior — nothing server-side catches it firing. If the model is prompt-injected mid-run, by hostile text in a web page, an issue or a search result, nothing moderates what it does next. With broad permissions and network access, an injected agent, or a fleet of them, becomes the attack: hammering a target, or uploading your code and secrets.
The guardrails are then the ones you wire: a sandbox, network and egress limits, secrets kept out of the agent’s reach, and rules on what may run and what may touch the internet. See AI agent permissions and how to sandbox an AI coding agent. This is the gap Contenox’s permission envelopes are built for: the routine work runs free, and the dangerous reach still asks.
4. What can your hardware run?
If you self-host, capacity and memory bandwidth cap the model before quality does. Rough tiers, with the full breakdown on the local pages:
- 8 to 12 GB GPU:
qwen3.5:9b, for short, focused tasks. - 24 GB GPU:
qwen3.8:27b, usable for real agent work. - 48 GB or more:
qwen3-coder-nextand other large models. - Won’t fit: a hosted model, or Ollama Cloud.
A mixture-of-experts model stretches a given card: Qwen3-30B-A3B holds 30.5B parameters but activates 3.3B per token, so it runs near a 3B’s speed while needing memory for the full 30B. Best Ollama models for coding gives the pick per GPU size, and how to run local LLMs for coding covers the bandwidth that sets token speed.
Then narrow the shortlist on your own repo
The four questions leave two or three candidates. The leaderboard cannot separate them for your stack; your own code can. Run the same small set of real tasks through each and compare.
- Pick five real tasks from recent work: a bug fix, a small feature, a new test, a refactor, and a question like “explain how billing works in this repo”.
- Write each task once, with a clear definition of done. See how to write good tasks for coding agents.
- Run each task with each model in the same agent, from the same commit, with the same permissions. Change only the model.
- Note whether it finished, how many turns it took, how long, and what it cost.
- Review each diff as a pull request. See how to review AI-written code.
Give each run its own branch, so every model starts from the same commit and you keep every result:
git switch -c try-model-a
git add -A && git commit -m "model-a attempt"
git switch main
Run the first line before the agent starts and the other two after it finishes. Then repeat with try-model-b. Keep a simple sheet:
task model-a model-b model-c
fix-coupon-bug pass, 9 turns pass, 22 turns fail
add-csv-export pass, in scope pass, overreach pass, in scope
explain-billing correct correct wrong module
Five tasks won’t give you statistics. They will reliably show a model that doesn’t fit your codebase. Rerun the sheet after every major model upgrade, including an upgrade of the model already in use: task files and AGENTS.md lines tuned to one model’s habits go stale, and the five tasks show it before a real task does.
To switch models mid-session: /model in Claude Code and in Codex, which also sets the reasoning level where the model supports it. In Contenox, the Model chip on the message box lists the models from every provider you connected, local ones included, so you can run the same task through each from one place.
Can I automate the comparison?
Yes. Give each model its own git worktree, run the same task in script mode, and commit what each produced. With Claude Code:
task="Expired coupons are still accepted at checkout. Fix it and add a test. Done when npm test passes."
for model in opus sonnet; do
git worktree add -b "try-$model" "../try-$model"
cd "../try-$model"
npm install
claude -p "$task" --model "$model" --max-turns 40 --allowedTools "Read" "Edit" "Write" "Bash(npm *)" > "../result-$model.md"
git add -A && git commit -qm "$model attempt"
cd -
done
Then compare: git diff main..try-opus --stat and git diff main..try-sonnet --stat show how much each touched, and the result-*.md files hold each model’s own summary. Run your tests on each branch yourself rather than trusting those summaries.
Two things to watch: each worktree needs its own dependency install, and two runs at once can collide on ports or a shared database, so run them one after another. The same loop works with any agent that has a script mode and a model flag. In Codex the claude -p line becomes codex exec -m "$model" --sandbox workspace-write "$task"; in OpenCode, opencode run -m "provider/$model" "$task".
Is the most expensive model worth it?
Compare cost per finished task, not price per token. A cheap model that needs three attempts and your help can cost more than an expensive one that gets it right once; your review time is part of the price. Once a model clears the bar on the five tasks above, a stronger one buys little for that kind of work — the question is whether one model is good enough, not which ranks highest.
Reasoning (“thinking”) settings matter as much as the model. Higher settings spend more output tokens every turn. Use them for hard debugging and design, not for renaming a variable. More in AI coding costs.
Should I use more than one model?
The local AI vs cloud AI guide compares where to run the work, what stays on your computer and how to try both on the same task.
Usually, yes. A common split:
- A strong model for planning, hard bugs and code nobody on the team knows well.
- A faster, cheaper model for routine edits, tests and boilerplate.
- A local model for code that must not leave your machine, or for offline work.
Claude Code’s own cost guide suggests the same: the cheaper model for most coding tasks, the top one kept for complex reasoning. Two models in one agent, switched with /model, is cheap. A pipeline of specialised models — one routes, one retrieves, one writes — is an engineering project: every extra model cuts the token bill and adds routing, latency and error handling someone has to maintain.
Related guides
- AI agent permissions: the guardrails a self-hosted model needs
- How to run local LLMs for coding: the hardware that sets token speed
- Best Ollama models for coding: local candidates by GPU size
- How to write good tasks for coding agents: a fair test needs a clear task
- How to review AI-written code: judge the diff, not the summary