The short answer
Full coding agent, least glue
OpenCode's docs ship an Ollama provider block, and Ollama documents a one-command launcher, ollama launch opencode. MIT licensed.
You already use Codex
Codex has reserved built-in ollama and lmstudio providers and an --oss flag. Apache-2.0.
Small, git-safe edits
Point it at ollama_chat/<model>. Every edit becomes a commit you can /undo. Apache-2.0.
Desktop app or repeatable non-coding tasks
Ollama is a built-in provider and installed models appear in the picker automatically. Apache-2.0.
First fix the context window
Most "the local agent ignores my tools" reports come down to context length. Ollama picks a default from your GPU memory: 4k tokens under 24 GiB of VRAM, 32k from 24 to 48 GiB, 256k at 48 GiB or more. It recommends at least 64,000 tokens for agents and coding tools, and its OpenCode and Codex pages both ask for 64k or more. OpenCode's own tip says that if tool calls aren't working, raise num_ctx, starting around 16k to 32k. Source.
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
# in another terminal: the CONTEXT column shows what was allocated
ollama psA larger context needs more memory. If ollama ps shows the model partly on CPU, it will be slow; Ollama advises avoiding CPU offload for best performance.
How each harness connects
| Harness | How it talks to Ollama | Where the setting lives | Ollama shortcut | License |
|---|---|---|---|---|
| OpenCode | OpenAI-compatible provider at http://localhost:11434/v1 | opencode.json | ollama launch opencode | MIT |
| Codex CLI | Built-in ollama / lmstudio provider, picked with --oss | ~/.codex/config.toml (oss_provider) | ollama launch codex | Apache-2.0 |
| Aider | OLLAMA_API_BASE + --model ollama_chat/<model> | env var or .aider.conf.yml | none documented | Apache-2.0 |
| goose | Built-in Ollama provider (OLLAMA_HOST) | goose configure or the desktop app | Ollama documents a goose page | Apache-2.0 |
| Claude Code | Ollama's Anthropic-compatible API (unsupported by Anthropic) | env / launcher | ollama launch claude | No license file (GitHub) |
Licenses from the GitHub API on Oct 18, 2026. "No license file" means GitHub detects none in anthropics/claude-code.
Rig 1: OpenCode + Ollama
This is OpenCode 1's documented Ollama block, plus a permission rule so edits and shell commands ask first. Replace <model> with a model you've pulled.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": { "baseURL": "http://localhost:11434/v1" },
"models": { "<model>": { "name": "<model> (local)" } }
}
},
"permission": { "edit": "ask", "bash": "ask" }
}Rig 2: Codex CLI + Ollama or LM Studio
# default local provider used when you run with --oss
oss_provider = "ollama" # or "lmstudio"codex --oss
# or let Ollama set up a dedicated Codex profile for the session
ollama launch codexIf oss_provider is unset, Codex prompts you to choose. The IDs openai, ollama and lmstudio are reserved, so don't define a custom provider with those names. Config reference.
Rig 3: Aider + Ollama
python -m pip install aider-install && aider-install
export OLLAMA_API_BASE=http://127.0.0.1:11434
ollama pull <model>
OLLAMA_CONTEXT_LENGTH=8192 ollama serve # Aider's doc example; raise it for bigger repos
aider --model ollama_chat/<model>Aider recommends the ollama_chat/ prefix over ollama/. Its doc example uses an 8k window; Ollama's own guidance for coding tools is 64k, so start higher if your hardware allows. Aider's repo was last pushed on May 22, 2026, per the GitHub API, which is slower than the other three.
Rig 4: goose + Ollama
goose configure # Configure Providers -> Ollama
export OLLAMA_HOST=http://localhost:11434
goose sessionIn goose Desktop, locally installed Ollama models show up in the model dropdown automatically. goose also reads AGENTS.md by default, so the same instructions file works here and in OpenCode and Codex.
Keeping private files local
A local model only keeps data local if nothing else in the rig phones out. Check three things before pointing a harness at private documents:
- Every model slot is local. Harnesses can use more than one model for different tasks; set all of them to your local provider.
- Web tools are off or ask first. In OpenCode,
"webfetch": "deny"underpermissionblocks fetches. - MCP servers are local. A remote MCP server sends your requests to its host.
See the private-docs recipe for a full read-only rig.
FAQ
What is the best agent harness for Ollama?
For a full coding agent, OpenCode: it has a documented Ollama provider and Ollama ships ollama launch opencode. If you already use Codex, its built-in Ollama provider and --oss flag are the shortest path. For small git-tracked edits, Aider.
How much context does a local coding agent need?
Ollama recommends at least 64,000 tokens for agents and coding tools. Its default is only 4k on GPUs with under 24 GiB of VRAM, which is too small for most agent loops.
Can Claude Code use a local model?
Ollama documents it via its Anthropic-compatible API, but Anthropic's docs say it doesn't support routing Claude Code to non-Claude models. It may work; it isn't supported by the vendor.
Which local model should I pick?
We don't rank local models. No benchmark we trust compares them inside these harnesses yet, so we won't invent a pick. Choose a tool-capable model that fits in GPU memory with a 64k window.
Get new rigs by email
New job recipes and harness changes, a few times a month. Each one with copy-ready config and dated sources.
Sources
- Ollama docs: context length · checked Oct 18, 2026
- Ollama docs: OpenCode · checked Oct 18, 2026
- Ollama docs: Codex CLI · checked Oct 18, 2026
- Ollama docs: Claude Code · checked Oct 18, 2026
- Ollama docs: goose · checked Oct 18, 2026
- OpenCode 1 docs: providers · checked Oct 18, 2026
- OpenCode 1 docs: permissions · checked Oct 18, 2026
- OpenCode 2 docs: migrate from V1 · checked Oct 18, 2026
- Codex docs: config reference · checked Oct 18, 2026
- Aider docs: Ollama · checked Oct 18, 2026
- goose docs: providers · checked Oct 18, 2026
- goose docs: .goosehints and AGENTS.md · checked Oct 18, 2026
- Claude Code docs: LLM gateway · checked Oct 18, 2026
- GitHub repo metadata (license, last push), via the GitHub API · checked Oct 18, 2026
Spotted something out of date? Email sternberg@mail.grokbot.com.