Use Ollama as a coding agent

Start Ollama, pull a model that calls tools, and run oharness -m ollama/<model>. The ollama provider is built in at localhost:11434 with no key, and OHarness discovers every model you have pulled.

Three commands

npm install -g oharness
ollama pull qwen3-coder:30b
oharness -m ollama/qwen3-coder:30b

Raise the context window first

This is the trap most people hit. Ollama serves a context far shorter than most models support unless told otherwise, and an agent fills it quickly with file contents and tool results. When the server does not report its window, OHarness assumes 128K, so the server truncates before the harness compacts. Start Ollama with a real window:

OLLAMA_CONTEXT_LENGTH=32768 ollama serve

Which model

One that supports tool calling, at 20–30B parameters or more for real agent work — coding-tuned models such as Qwen3-Coder, or general ones such as gpt-oss. Smaller models answer questions well but lose track of multi-step edits. Everything you have pulled shows up under /models.

Worth knowing

  • Ollama on another machine: override the provider's baseUrl in ~/.oharness/config.json (shape below).
  • Local and hosted models share a session: read with Ollama, then /model to a hosted model for a hard step.
  • Running fully offline lists the little network traffic that remains and how to turn it off.

Common questions

Can I use Ollama with a coding agent like Claude Code?

Yes. OHarness has Ollama as a built-in provider: start Ollama, pull a tool-calling model and run oharness -m ollama/<model>. No key or config file is needed.

Why does my Ollama coding agent forget what it did earlier?

Ollama's default context window is much smaller than the model's. Set OLLAMA_CONTEXT_LENGTH (or num_ctx) to 32K or more so the agent's compaction, not the server's truncation, decides what is summarised.

Which Ollama models support tool calling?

Ollama marks tool-capable models with a tools tag in its library. Qwen3-Coder and gpt-oss are common choices for coding agents.

Ollama reference

Provider idollama
Base URLhttp://localhost:11434/v1
ProtocolOpenAI-compatible chat completions
API keyNone — the endpoint is local.
Model discoveryYes — the model list is asked of the endpoint rather than shipped.

Connecting it

Nothing to configure and no key to obtain. Start the server on its usual port and the provider appears in the model picker; the harness asks it for its own model list rather than shipping one.

Pointing it somewhere else

A regional host, a gateway, or a server of your own. Overrides in ~/.oharness/config.json are field level, so changing the endpoint does not mean restating the rest of the provider — this is the whole block, shown holding the default so the shape is clear:

{
  "providers": {
    "ollama": {
      "baseUrl": "http://localhost:11434/v1"
    }
  }
}

What you get either way

The same agent loop, the same tools, the same MCP servers and the same permission rules, whichever provider is underneath — and switching between them mid-session converts nothing, because history is never stored in a vendor’s shape. What an agent harness is covers why that is the hard part, and the providers reference covers the catalogue itself.

All 34 providers · Install OHarness