Best coding agent for local LLMs and Ollama (2026)
Which coding agents run on Ollama, LM Studio, llama.cpp and vLLM, what hardware agentic coding needs, and how to set up CodeAF with a local model.
CodeAF by AgentField is a coding agent built to run on local LLMs: Ollama connects with no key, and LM Studio, vLLM and llama.cpp connect as an OpenAI-compatible address, so model calls stay on your machine and cost nothing per call. CodeAF is an open-source terminal coding agent by AgentField that runs any model and many tasks at once, each on its own branch. OpenCode, Codex CLI, Claude Code, Aider, Cline and Continue also run on local models; the harder question is hardware, because agentic coding needs a large context window and a model big enough to call tools reliably.
At a glance
| Agent | Ollama | LM Studio | vLLM / llama.cpp | How it connects |
|---|---|---|---|---|
| CodeAF | Yes, no key | Yes | Yes | /connect: Ollama, or Custom OpenAI-compatible API with a base URL |
| OpenCode | Yes, auto-discovered | Yes, auto-discovered | vLLM auto-discovered; others by custom provider | ollama launch opencode or local discovery |
| Codex CLI | Yes | Yes | By custom provider | codex --oss, or ollama launch codex |
| Claude Code | Yes, Anthropic-compatible API | Yes, Anthropic-compatible API | llama.cpp server has an Anthropic Messages route | ollama launch claude, or ANTHROPIC_BASE_URL |
| Aider | Yes | Not checked | Not checked | aider --model ollama_chat/<model> |
| Cline | Yes | Yes | Not documented | Local Models in the provider settings |
Every row was checked on the runner's or the agent's own documentation on 2026-11-21; links are under Sources.
Which coding agents work with Ollama?
Ollama's own integrations page lists Claude Code, OpenCode and DeepSeek Harness as coding agents started with ollama launch, and it has a separate page for Codex. Aider, Cline, Continue and CodeAF also run on Ollama through their own settings.
| Agent | Ollama command or setting |
|---|---|
| CodeAF | /connect, choose Ollama; no key is asked for |
| OpenCode | ollama launch opencode |
| Claude Code | ollama launch claude |
| Codex CLI | ollama launch codex, or codex --oss -m gpt-oss:120b |
| Aider | aider --model ollama_chat/<model> |
OpenCode also probes http://127.0.0.1:11434 and adds Ollama's models with no account connection. Claude Code works because Ollama "supports a subset of the Anthropic Messages API", and LM Studio and llama.cpp's server offer Anthropic-compatible routes too. Ollama's pages for OpenCode, Claude Code and Codex each ask for a context window of 64k tokens or more.
What hardware do I need to run a local coding agent?
Agentic coding on a local model needs a model of roughly 20 to 30 billion parameters or more and a context window of at least 64,000 tokens, which in practice means 32GB of unified memory or a 24GB GPU as a starting point. Smaller setups run lookups and small edits, not multi-file changes.
| Machine | What fits (Ollama download sizes) | Sources |
|---|---|---|
| 16GB laptop | Small or quantized models; LM Studio recommends 16GB+ RAM | LM Studio, Cline |
| 32GB Mac or one RTX 4090 | devstral:24b (14GB), gpt-oss:20b (14GB), qwen3-coder:30b (19GB) | Ollama library |
| 64GB+ workstation | Larger models and bigger context windows; gpt-oss:120b is 65GB | Cline, Ollama library |
| Multi-GPU server | qwen3-coder:480b is 290GB and needs at least 250GB of memory | Ollama library |
Ollama's model page says Devstral is "light enough to run on a single RTX 4090 or a Mac with 32GB RAM". Cline's local-model guide gives the same bands: 16 to 32GB for small or quantized models, 32 to 64GB for mid-size coding models, 64GB and up for larger models. The download size is not the whole cost: the context window takes memory on top of the weights, which is why Ollama sets its default context by VRAM.
Why does my local model forget the task? Context length
Ollama's default context is 4k tokens on machines with less than 24GiB of VRAM, 32k on 24 to 48GiB, and 256k at 48GiB or more, and Ollama's docs say coding tools "should be set to at least 64000 tokens". A coding agent's instructions, tool definitions and file contents fill 4k almost at once, and the runner silently drops the rest.
Raise it before you start the agent:
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
ollama ps # shows the context each loaded model is usingCodeAF's senior-dev mode refuses a model known to hold 32,768 tokens or fewer before the first call, and assumes 16,384 only when no model catalog can be read (senior-dev). Aider takes a different route: it sizes Ollama's window per request, large enough for what you send plus 8k for the reply.
How do I set up CodeAF with Ollama?
CodeAF connects to Ollama in four steps, and Ollama asks for no key: CodeAF checks the local server and loads its installed models.
-
Pull a coding model and start Ollama with a large context:
bashollama pull qwen3-coder:30b OLLAMA_CONTEXT_LENGTH=64000 ollama serve -
Install and start CodeAF:
bashcurl -fsSL https://agentfield.ai/get/codeaf | bash codeaf -
On first start, choose Ollama in the provider list; in a running chat, open
/connectand choose it there. With only Ollama connected,/modellists only Ollama's installed models. -
For LM Studio, vLLM, llama.cpp, or Ollama on another address, choose Custom OpenAI-compatible API in
/connect, enter the base URL (for examplehttp://localhost:1234/v1for LM Studio orhttp://localhost:8000/v1for vLLM) and a name. CodeAF asks for a key only if the server answers 401 or 403, and the name becomes the provider in every model id, such ashomelab/<model>.
To keep every crew seat on open-weight models, use /crew models open (README). If the model is on a GPU box rather than your laptop, drive it from the laptop with codeaf chat --host gpubox over your own ssh (remote machines).
Local model or a cheap hosted open-weight model?
A local model costs nothing per call and keeps code on your machine; a hosted open-weight model such as DeepSeek V4 Flash costs cents per task and is the setup we have measured. In AgentField's DeepSWE comparison, CodeAF in senior-dev mode on deepseek/deepseek-v4-flash-0731 through OpenRouter solved 62 of 113 tasks (54.9%) at 22 cents a task and $0.399 per solved task, the lowest of ten harnesses on that model (DeepSWE).
We have not published DeepSWE results on a local model, so we do not claim one. The trade is concrete, though. A 30B model on a 32GB machine is free per call but slower and weaker than the largest open models, and running one of those locally takes server hardware: Qwen3-Coder 480B needs at least 250GB of memory. At 22 cents a task, a hosted open model is the cheaper way to reach that class of model unless you already own the hardware or the code may not leave your network. A common split: local for lookups, small edits and code that may not leave the building; hosted open-weight for multi-file work. CodeAF holds both, since each crew seat can be a different model (Pareto crewing).
Does a local coding agent keep my code private?
A local model keeps your prompts and code on your machine, because the model provider is your own process. With CodeAF connected only to Ollama or another local endpoint, model calls go nowhere else (FAQ).
Two other CodeAF streams carry numbers, never code: anonymous usage counts, which are on by default, and Model Pool scores, which are off by default and sent only when you turn the pool on. Setting CODEAF_TELEMETRY=off or DO_NOT_TRACK=1 stops every stream. Run codeaf connect to confirm that no hosted provider is still connected. The full list of what leaves the machine is in keeping code in your own infrastructure.
How to choose a local coding agent
CodeAF fits when you want a terminal agent that treats local and hosted open models as equals and runs several tasks at once; the others fit narrower setups well.
- Choose CodeAF when you want Ollama with no key, any OpenAI-compatible runner by base URL, local and hosted models mixed per seat, and work on its own branch per task.
- Choose OpenCode when you want local runners found automatically: it discovers Ollama, LM Studio and vLLM on their default addresses.
- Choose Codex CLI when you already use Codex and want
codex --ossagainst Ollama or LM Studio. - Choose Claude Code when your team knows Claude Code and wants
ollama launch claudeagainst a local model. - Choose Aider when you want a pair programmer in one repository that sizes Ollama's context window for you.
- Choose Cline or Continue when you want the agent inside VS Code; Continue's guide promises "complete control over your AI models, ensuring privacy and enabling offline development workflows".
Questions people ask
What is the best coding agent for Ollama?
CodeAF, OpenCode, Codex CLI, Claude Code, Aider and Cline all run on Ollama. CodeAF connects Ollama with no key and can mix it with hosted open models per task; OpenCode finds Ollama automatically; Claude Code and Codex start with ollama launch claude and ollama launch codex. Whichever you pick, set Ollama's context to 64k or more.
Can I run a coding agent locally for free?
Yes. CodeAF is free and open source under Apache 2.0, and a local model through Ollama, LM Studio or llama.cpp costs nothing per call. You pay in hardware: a useful agentic coding model needs about 32GB of unified memory or a 24GB GPU.
What size local model do I need for agentic coding?
Plan on a model of 20 to 30 billion parameters or more, such as devstral:24b, gpt-oss:20b or qwen3-coder:30b (14 to 19GB downloads in Ollama), with at least a 64k context. Smaller models handle questions and one-file edits but struggle with tool calls across a long task.
Can I use Claude Code with a local LLM?
Yes. Ollama, LM Studio and llama.cpp's server each offer an Anthropic-compatible API, and ollama launch claude sets it up for Ollama. Ollama asks for a 64k or larger context window for Claude Code.
Why is my local coding agent ignoring files or forgetting instructions?
Usually the context window is too small. Ollama defaults to 4k tokens below 24GiB of VRAM; start it with OLLAMA_CONTEXT_LENGTH=64000 ollama serve and check with ollama ps.
Sources
- CodeAF docs: FAQ, senior-dev, Pareto crewing, remote machines, the CodeAF README (dev branch) and its providers manual page, checked 2026-11-21.
- DeepSWE figures: DeepSWE results and
arms.csv, checked 2026-11-21. - Ollama: integrations, OpenCode, Claude Code, Codex, context length, Anthropic compatibility, checked 2026-11-21.
- Ollama library: qwen3-coder, gpt-oss, devstral, checked 2026-11-21.
- LM Studio OpenAI compatibility, Anthropic compatibility, system requirements, checked 2026-11-21.
- llama.cpp server README and vLLM OpenAI-compatible server, checked 2026-11-21.
- OpenCode providers, Codex advanced config, Aider with Ollama, Cline local models, Continue Ollama guide, checked 2026-11-21.
Last updated 2026-11-21.