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:27b for quality, qwen3.6:35b-a3b-coding or qwen3-coder:30b when you want faster mixture-of-experts output.
  • 16GB: gpt-oss:20b for agent work; qwen2.5-coder:14b for chat and edits.
  • 8GB: qwen3.5:9b for agents, qwen2.5-coder:7b for chat, qwen2.5-coder:1.5b for autocomplete.
  • Every tier: set OLLAMA_CONTEXT_LENGTH=64000 and confirm with ollama ps that 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 tierModelTagQuantSize on diskMax contextTool callingBest use
8GB VRAMQwen3.5 9Bqwen3.5:9bQ4_K_M6.6GB256KYes, Qwen3.5 parser issue openLight agent tasks
8GB VRAMQwen2.5-Coder 7Bqwen2.5-coder:7bQ4_K_M4.7GB32KTagged, parsing bugs reportedChat, edits, Aider
8GB VRAMQwen2.5-Coder 1.5Bqwen2.5-coder:1.5bQ4_K_M986MB32KNot neededTab autocomplete
12GB VRAMGemma 4 12Bgemma4:12bQ4_K_M7.6GB256KYes, issues reportedAgents with room for context
12-16GB VRAMQwen2.5-Coder 14Bqwen2.5-coder:14bQ4_K_M9.0GB32KTagged, parsing bugs reportedChat and single-file edits
16GB VRAMgpt-oss 20Bgpt-oss:20bMXFP414GB128KYesAgent loops, reasoning
24GB VRAMQwen3.8 27Bqwen3.8:27b4-bit default18GB256KYesBest overall quality
24GB VRAMQwen3-Coder 30Bqwen3-coder:30bQ4_K_M19GB256KYes, issues reportedFast MoE coding agent
24-32GBQwen3.6 35B-A3B codingqwen3.6:35b-a3b-codingQ4_K_M23GB256KYesFast agent loops with 32GB
32GB+Laguna XS 2.1laguna-xs-2.1Q4_K_M20GB256KYesLong-horizon agent runs
64GB+Qwen3-Coder-Nextqwen3-coder-nextQ4_K_M52GB256KYesRepository-scale work
80GB+gpt-oss 120Bgpt-oss:120bMXFP465GB128KYesWorkstation 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 ps

Check 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 gemma4 on 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.

ModelBenchmarkScorePublished by
Qwen3.8 27BTerminal Bench 2.173.0Qwen (vs 63.4 for Qwen3.6 27B)
Qwen3.8 27BSWE-bench Pro61.7Qwen (vs 53.5 for Qwen3.6 27B)
Qwen3.8 27BLiveCodeBench v690.3Qwen (vs 83.9 for Qwen3.6 27B)
Qwen3.6 27BSWE-bench Verified77.2Qwen
Qwen3.6 35B-A3BSWE-bench Verified73.4Qwen
Laguna XS 2.1SWE-bench Verified70.9%Poolside, on its Ollama card
Gemma 4 31BLiveCodeBench v680.0%Google, on its Ollama card
Qwen3.5 9BLiveCodeBench v665.6Qwen (GPT-OSS-20B: 74.6)
Devstral 24BSWE-bench Verified46.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.

ToolSetupContext settingModel fit
Claude Codeollama launch claude, or set ANTHROPIC_BASE_URL=http://localhost:11434, ANTHROPIC_AUTH_TOKEN=ollama, ANTHROPIC_API_KEY="", then claude --model qwen3.8:27b64k+Qwen3.8, Qwen3.6 coding, Qwen3-Coder-Next
Continueconfig.yaml: provider: ollama, model: the exact ollama list name, capabilities: [tool_use] for agent modecontextLength per modelQwen3.6 coding for agent, qwen2.5-coder:1.5b for autocomplete
ClineSettings, API Provider Ollama, pick the model, set Context Window32K minimumgpt-oss 20B, Qwen3.8, Qwen3.6 coding
Aiderexport OLLAMA_API_BASE=http://127.0.0.1:11434, then aider --model ollama_chat/qwen2.5-coder:14bautomatic per requestQwen2.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.

References