The best Ollama model for coding in September 2026 depends on your memory: qwen3.8:27b (18GB) is the top pick for a 24GB GPU or a 32GB+ Mac, gpt-oss:20b (14GB) fits a 16GB card, and qwen3.5:9b (6.6GB) is the 8GB pick for agent work. Whatever you pick, raise Ollama's context window to at least 64k before pointing Claude Code, Continue, Cline, or Aider at it, because the default under 24GB of VRAM is only 4k tokens (Sources: Ollama library, Ollama docs).
That context rule matters more than most model rankings admit. A 27B model starved at 4k tokens will lose your files mid-task, while a smaller model with 64k of room can finish the job. The matrix below maps each memory tier to a specific tag, its size on disk, its maximum context, and whether its tool calls are known to work in coding agents.
Key takeaways:
- 24GB+ GPU or 32GB+ Mac:
qwen3.8:27bfor quality,qwen3.6:35b-a3b-codingorqwen3-coder:30bwhen you want faster mixture-of-experts output. - 16GB:
gpt-oss:20bfor agent work;qwen2.5-coder:14bfor chat and edits. - 8GB:
qwen3.5:9bfor agents,qwen2.5-coder:7bfor chat,qwen2.5-coder:1.5bfor autocomplete. - Every tier: set
OLLAMA_CONTEXT_LENGTH=64000and confirm withollama psthat the model runs 100% on GPU.
Best Ollama model for coding by VRAM: the decision matrix
Size on disk is the weight file Ollama downloads, so treat it as the floor of what the model needs in memory. The KV cache for your context window sits on top of it, which is why a 23GB model is a tight fit on a 24GB card. Every size and context value below comes from the model's tags page on ollama.com, checked on 2026-09-27 (Source: Ollama library).
| Memory tier | Model | Tag | Quant | Size on disk | Max context | Tool calling | Best use |
|---|---|---|---|---|---|---|---|
| 8GB VRAM | Qwen3.5 9B | qwen3.5:9b | Q4_K_M | 6.6GB | 256K | Yes, Qwen3.5 parser issue open | Light agent tasks |
| 8GB VRAM | Qwen2.5-Coder 7B | qwen2.5-coder:7b | Q4_K_M | 4.7GB | 32K | Tagged, parsing bugs reported | Chat, edits, Aider |
| 8GB VRAM | Qwen2.5-Coder 1.5B | qwen2.5-coder:1.5b | Q4_K_M | 986MB | 32K | Not needed | Tab autocomplete |
| 12GB VRAM | Gemma 4 12B | gemma4:12b | Q4_K_M | 7.6GB | 256K | Yes, issues reported | Agents with room for context |
| 12-16GB VRAM | Qwen2.5-Coder 14B | qwen2.5-coder:14b | Q4_K_M | 9.0GB | 32K | Tagged, parsing bugs reported | Chat and single-file edits |
| 16GB VRAM | gpt-oss 20B | gpt-oss:20b | MXFP4 | 14GB | 128K | Yes | Agent loops, reasoning |
| 24GB VRAM | Qwen3.8 27B | qwen3.8:27b | 4-bit default | 18GB | 256K | Yes | Best overall quality |
| 24GB VRAM | Qwen3-Coder 30B | qwen3-coder:30b | Q4_K_M | 19GB | 256K | Yes, issues reported | Fast MoE coding agent |
| 24-32GB | Qwen3.6 35B-A3B coding | qwen3.6:35b-a3b-coding | Q4_K_M | 23GB | 256K | Yes | Fast agent loops with 32GB |
| 32GB+ | Laguna XS 2.1 | laguna-xs-2.1 | Q4_K_M | 20GB | 256K | Yes | Long-horizon agent runs |
| 64GB+ | Qwen3-Coder-Next | qwen3-coder-next | Q4_K_M | 52GB | 256K | Yes | Repository-scale work |
| 80GB+ | gpt-oss 120B | gpt-oss:120b | MXFP4 | 65GB | 128K | Yes | Workstation or Mac Studio |
Inference: leave a few GB of headroom above the file size for a 64k context; the exact figure depends on each model's layer and attention-head counts. Our KV cache size guide shows the per-model math, and the LLM VRAM calculator runs it for any tag.
Why context length decides more than the model
Ollama sizes the default context from your VRAM: 4k tokens below 24 GiB, 32k from 24 to 48 GiB, and 256k at 48 GiB or more. The same documentation says tasks such as agents and coding tools "should be set to at least 64000 tokens" (Source: Ollama docs).
That gap is where most "this model is bad at coding" complaints start. A coding agent sends a system prompt, tool schemas, and file contents before it writes a line. On an 8GB or 16GB card, all of that has to fit in 4k tokens unless you change the setting, and the oldest turns get dropped.
The fix is one environment variable on the server:
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
ollama psCheck the CONTEXT and PROCESSOR columns in ollama ps. You want your chosen context and 100% GPU; a CPU split means the model plus cache no longer fit, and speed drops sharply (Source: Ollama docs).
The editors disagree slightly on the floor. Ollama's Cline guide asks for at least 32K, its Claude Code guide asks for 64k or more, and Aider sizes the window per request on its own (Sources: Ollama docs, Aider docs). Aider's page still says Ollama defaults to 2k, which predates the VRAM-based defaults; trust the Ollama figure. Open reports also show Claude Code (Ollama issue 15316) and the Cline CLI (Cline issue 13989) failing to auto-compact when the local window fills, so long sessions may still need a manual /compact or a restart. If you run Ollama in a container, the Ollama Docker GPU setup covers passing the variable through.
Which Ollama models handle tool calls for agentic coding
A tools badge on ollama.com means the model template declares tool support. It does not guarantee your editor receives a structured tool call. In an open Cline report from 2026-09-23, qwen2.5-coder:14b on Ollama 0.34.2 listed tools under capabilities, yet the raw /api/chat response put the tool call in message.content with no tool_calls field (Source: Cline issue 14453).
The same pattern appears across trackers:
- Continue: an open issue from 2026-07-29 reports Qwen3-Coder 30B on Ollama returning tool calls as plain text instead of executing them (Continue issue 13057).
- Ollama: a report on Qwen 3.5 27B tool calling, open since 2026-02-27, was still being confirmed on 2026-08-31 (Ollama issue 14493).
- Claude Code: a user running
gemma4on two 12GB RTX 3060 cards got looping "Invalid tool parameters" errors (Ollama issue 15390).
This is why the matrix separates "Yes" from "Tagged, parsing bugs reported". Qwen2.5-Coder is still a solid choice for chat, single-file edits, and Aider, which Aider connects through its ollama_chat/ provider (Source: Aider docs). Inference: Aider is less exposed to this bug, because it asks for edits in its own text formats rather than relying on native tool calls. For agent loops, prefer the newer tags that Ollama and the model vendors describe as agent-trained: Qwen3.8, Qwen3.6 coding, gpt-oss, and Qwen3-Coder-Next, whose card says it "works with coding agents like Claude Code, Qwen Code, Cline, and OpenCode out of the box" (Source: Ollama library).
Qwen3.8 reached Ollama a day before this check, so its tool calling has no public track record yet, and it inherits the Qwen3.5 architecture whose Ollama parser issue is still open. If it misbehaves in your agent, qwen3.6:27b-coding (18GB) is the same-size fallback.
A quick self-check before blaming the model: run ollama show <model> and confirm tools appears under Capabilities, then watch your editor's log for a real tool call rather than JSON printed into the chat.
What the published coding benchmarks say
Vendor model cards publish coding scores, but each vendor runs its own harness, so compare rows within one table rather than across tables. The numbers below are copied from the primary cards.
| Model | Benchmark | Score | Published by |
|---|---|---|---|
| Qwen3.8 27B | Terminal Bench 2.1 | 73.0 | Qwen (vs 63.4 for Qwen3.6 27B) |
| Qwen3.8 27B | SWE-bench Pro | 61.7 | Qwen (vs 53.5 for Qwen3.6 27B) |
| Qwen3.8 27B | LiveCodeBench v6 | 90.3 | Qwen (vs 83.9 for Qwen3.6 27B) |
| Qwen3.6 27B | SWE-bench Verified | 77.2 | Qwen |
| Qwen3.6 35B-A3B | SWE-bench Verified | 73.4 | Qwen |
| Laguna XS 2.1 | SWE-bench Verified | 70.9% | Poolside, on its Ollama card |
| Gemma 4 31B | LiveCodeBench v6 | 80.0% | Google, on its Ollama card |
| Qwen3.5 9B | LiveCodeBench v6 | 65.6 | Qwen (GPT-OSS-20B: 74.6) |
| Devstral 24B | SWE-bench Verified | 46.8% | Mistral, OpenHands scaffold |
Qwen's card places Qwen3.8 27B ahead of its predecessor on every coding row it reports (Source: Qwen model cards). Qwen3.6's own card, which the Qwen3.6-27B page hosts, lists 77.2 on SWE-bench Verified against 52.0 for Gemma 4 31B under Qwen's harness. The Laguna and Gemma rows come from their Ollama model cards (Source: Ollama library).
Treat these as a shortlist filter, not a ranking. An independent 16GB test on the Hugging Face forum found that repeat runs flipped single-shot rankings among six Ollama models, and the most-cited score belonged to a sampling path that was not the common one. Your own repository is the benchmark that counts.
Apple Silicon and unified memory
On a Mac, the model shares one memory pool with macOS and your editor, so a 32GB Mac behaves more like a 24GB GPU than a 32GB one. Vendor cards give the clearest guidance: Devstral says it fits "a Mac with 32GB RAM", Laguna XS 2.1 targets "a Mac with 36 GB of RAM", and the Qwen3-Coder 480B card asks for at least 250GB of memory or unified memory (Source: Ollama library).
Two practical notes follow from the tag data. Qwen3.8 ships a qwen3.8:27b-mlx tag at 18GB for Apple's MLX runtime, and Laguna XS 2.1's card currently warns of an issue on macOS that its team is investigating (Source: Ollama library).
Inference: by tier, a 16GB Mac should run qwen3.5:9b or qwen2.5-coder:7b; a 32GB to 36GB Mac can run qwen3.8:27b or qwen3.6:35b-a3b-coding with a 64k window; 64GB and up opens qwen3-coder-next. If you are on an 8GB machine, read our 8GB RAM test before pulling anything larger than 4B.
How to connect Claude Code, Continue, Cline, and Aider
Each tool talks to Ollama at http://localhost:11434, but each expects a slightly different setup. The table gives the shortest working path and the model fit for each.
| Tool | Setup | Context setting | Model fit |
|---|---|---|---|
| Claude Code | ollama launch claude, or set ANTHROPIC_BASE_URL=http://localhost:11434, ANTHROPIC_AUTH_TOKEN=ollama, ANTHROPIC_API_KEY="", then claude --model qwen3.8:27b | 64k+ | Qwen3.8, Qwen3.6 coding, Qwen3-Coder-Next |
| Continue | config.yaml: provider: ollama, model: the exact ollama list name, capabilities: [tool_use] for agent mode | contextLength per model | Qwen3.6 coding for agent, qwen2.5-coder:1.5b for autocomplete |
| Cline | Settings, API Provider Ollama, pick the model, set Context Window | 32K minimum | gpt-oss 20B, Qwen3.8, Qwen3.6 coding |
| Aider | export OLLAMA_API_BASE=http://127.0.0.1:11434, then aider --model ollama_chat/qwen2.5-coder:14b | automatic per request | Qwen2.5-Coder 14B or 32B, Qwen3.8 |
Claude Code reaches Ollama through its Anthropic-compatible API, and Ollama's guide adds that basic chat and file edits work with compatible models while hosted web search is not fully supported (Source: Ollama docs). Continue's guide warns that some models still show "Agent mode is not supported" even with tool_use set, which usually means the model lacks working tool calls (Source: Continue docs). Aider recommends the ollama_chat/ prefix over ollama/ (Source: Aider docs).
Choosing between runtimes is a separate question. If you are weighing Ollama against alternatives for this setup, see LM Studio vs Ollama and Ollama vs llama.cpp.
Older coding models you can skip
Two names still top old "best Ollama coding model" lists but fall behind on the two things agents need. codestral (22B, 13GB) has a 32K context, no tools badge, and was last updated two years ago. deepseek-coder-v2 (16B lite, 8.9GB) also carries no tools badge, and most of its quantized tags list only a 4K context (Source: Ollama library).
Both remain fine for fill-in-the-middle completion or plain chat. For anything that edits files through an agent, the Qwen3.5 through Qwen3.8 generation, gpt-oss, and Gemma 4 give you tool support plus 128K to 256K of maximum context at similar or smaller sizes.
FAQ
Which is the best Ollama model for coding?
For a 24GB GPU or a 32GB+ Mac, qwen3.8:27b is the best Ollama model for coding as of September 2026: 18GB on disk, 256K maximum context, tool calling, and higher vendor-reported coding scores than Qwen3.6 27B. On 16GB use gpt-oss:20b; on 8GB use qwen3.5:9b.
Is Ollama ai good for coding?
Yes, for private and offline work, if you pick a tool-calling model and raise the context. Ollama runs the models; quality comes from the model you pull. Set OLLAMA_CONTEXT_LENGTH to 64000, because the default below 24GB of VRAM is 4k tokens, which truncates the files a coding agent needs to read.
What is the best Ollama coding model for a 16GB laptop?
On a 16GB GPU, gpt-oss:20b (14GB, MXFP4, 128K context, tool calling) is the strongest agent option. On a 16GB Mac, where macOS shares that memory, step down to qwen3.5:9b (6.6GB) or qwen2.5-coder:7b (4.7GB) so the model and a 64k context fit without swapping.
Which Ollama model is the fastest?
Mixture-of-experts models run fastest for their quality because only a few billion parameters are active per token. qwen3-coder:30b activates 3.3B of 30B, and qwen3.6:35b-a3b-coding activates about 3B. On small machines, qwen2.5-coder:1.5b (986MB) is the fastest practical choice for tab autocomplete, and keeping the whole model on the GPU matters more than parameter count.
Related coverage
- LLM VRAM Calculator: RAM, Quantization, and Model Fit
- KV Cache Size: How Much VRAM It Uses and How to Cut It
- Can You Run a Local LLM on 8GB RAM? M1 Mac Test
- Ollama vs llama.cpp: Which Is Faster for Local LLMs?
References
- Aider docs - https://aider.chat/docs/llms/ollama.html
- Cline issue 14453 - https://github.com/cline/cline/issues/14453
- Continue docs - https://docs.continue.dev/guides/ollama-guide
- Ollama docs - https://docs.ollama.com/context-length
- Ollama library - https://ollama.com/library
- Qwen model cards - https://huggingface.co/Qwen/Qwen3.8-27B

