Last updated · Santosh Kumar Radha

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

AgentOllamaLM StudiovLLM / llama.cppHow it connects
CodeAFYes, no keyYesYes/connect: Ollama, or Custom OpenAI-compatible API with a base URL
OpenCodeYes, auto-discoveredYes, auto-discoveredvLLM auto-discovered; others by custom providerollama launch opencode or local discovery
Codex CLIYesYesBy custom providercodex --oss, or ollama launch codex
Claude CodeYes, Anthropic-compatible APIYes, Anthropic-compatible APIllama.cpp server has an Anthropic Messages routeollama launch claude, or ANTHROPIC_BASE_URL
AiderYesNot checkedNot checkedaider --model ollama_chat/<model>
ClineYesYesNot documentedLocal 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.

AgentOllama command or setting
CodeAF/connect, choose Ollama; no key is asked for
OpenCodeollama launch opencode
Claude Codeollama launch claude
Codex CLIollama launch codex, or codex --oss -m gpt-oss:120b
Aideraider --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.

MachineWhat fits (Ollama download sizes)Sources
16GB laptopSmall or quantized models; LM Studio recommends 16GB+ RAMLM Studio, Cline
32GB Mac or one RTX 4090devstral:24b (14GB), gpt-oss:20b (14GB), qwen3-coder:30b (19GB)Ollama library
64GB+ workstationLarger models and bigger context windows; gpt-oss:120b is 65GBCline, Ollama library
Multi-GPU serverqwen3-coder:480b is 290GB and needs at least 250GB of memoryOllama 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:

bash
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
ollama ps   # shows the context each loaded model is using

CodeAF'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.

  1. Pull a coding model and start Ollama with a large context:

    bash
    ollama pull qwen3-coder:30b
    OLLAMA_CONTEXT_LENGTH=64000 ollama serve
  2. Install and start CodeAF:

    bash
    curl -fsSL https://agentfield.ai/get/codeaf | bash
    codeaf
  3. On first start, choose Ollama in the provider list; in a running chat, open /connect and choose it there. With only Ollama connected, /model lists only Ollama's installed models.

  4. For LM Studio, vLLM, llama.cpp, or Ollama on another address, choose Custom OpenAI-compatible API in /connect, enter the base URL (for example http://localhost:1234/v1 for LM Studio or http://localhost:8000/v1 for 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 as homelab/<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 --oss against Ollama or LM Studio.
  • Choose Claude Code when your team knows Claude Code and wants ollama launch claude against 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

Last updated 2026-11-21.