Best Ollama harness for coding: Claude Code, OpenCode, Codex
Updated
Ollama defaults to 4,096 tokens on both a single 8 GiB GPU and a single 16 GiB GPU. With the default f16 context cache, Contenox’s native selector estimated 58,258 tokens on 8 GiB with Nanbeige4 3B Thinking and 63,858 tokens on 16 GiB with Gemma 4 12B. Ollama’s default can be raised. The Contenox figures are estimates of how much context can stay resident with each selected model, using 80% of the card’s nominal memory. Ollama’s context guide · Selector method
| Single GPU | Ollama default (adjustable) | Contenox native estimate by model and cache |
|---|---|---|
| 8 GiB | 4,096 tokens | 58,258 tokens · Nanbeige4 3B Thinking · f16 |
| 8 GiB | 4,096 tokens | 52,578 tokens · Qwen3.5 4B · q8_0 |
| 16 GiB | 4,096 tokens | 63,858 tokens · Gemma 4 12B · f16 |
| 16 GiB | 4,096 tokens | 42,045 tokens · Ministral 3 14B · q8_0 |
Ollama recommends at least 64,000 tokens for coding agents. At its default, tool definitions, source code and test output all compete for 4,096 tokens. An agent can lose the original error message before it finishes repairing the test. Raising the window uses more memory and can move some model layers onto the CPU, slowing generation.
The choice of inference engine matters here. Contenox Harness can read a failing test, edit the source and rerun the test under the project’s permission rules. With Ollama connected, Ollama manages the model’s memory. With native Local AI selected, Contenox estimates how much context each candidate model can keep in the available memory and uses that estimate to choose a model for agent work. Compare 8 and 16 GiB GPUs
The harnesses compared#
| Harness | Connect to Ollama | API it uses | Needs tool calls | Setup | Best with |
|---|---|---|---|---|---|
| Contenox Harness | Backends → Providers → Ollama | Ollama when selected | Yes for agent tools | Connect a server or choose native Local AI | Project permissions and a choice of inference engines on the same machine |
| Claude Code | ollama launch claude |
Anthropic Messages | Yes | One command | Claude Code workflows with a tool-capable model and enough context |
| Codex CLI | ollama launch codex, or codex --oss |
Responses | Yes | One command | Terminal agent workflows with enough context for instructions and tools |
| OpenCode | Select an installed Ollama model with /models, or use ollama launch opencode |
Chat Completions | Yes | Model picker or explicit configuration | Tool-capable models with a working context sized for the project |
| Aider | aider --model ollama_chat/<model> |
Ollama chat API | No for text edits | Install the Python package | Focused file edits. Last main commit on 22 May 2026. Maintenance details |
| Goose | Built-in Ollama provider, OLLAMA_HOST |
Ollama provider | Yes | Pick the provider, raise the context | Larger models |
| Cline | Ollama provider in VS Code | Ollama provider | Yes | Settings in VS Code | Editor users; turn on Use Compact Prompt |
| Continue (legacy) | Existing provider: ollama configuration |
Ollama provider | For agent mode | Existing YAML installations | Maintaining an existing setup |
| DeepSeek Harness | ollama launch dsh |
Set up by Ollama | Yes | One command (Node.js) | DeepSeek cloud models; developer preview |
For a personal assistant that works through a browser dashboard or messaging channels, Ollama also supports ollama launch openclaw. OpenClaw’s own onboarding can use a detected provider account, a supported sign-in or an API key and checks that the selected model answers. Ollama’s OpenClaw guide · OpenClaw onboarding
What makes a harness good with local models?#
Three things, and the big agents differ on all of them.
1. How a proposed edit becomes a file change. With a tool-calling harness such as Contenox or OpenCode, the model can ask to read a file, apply a change or run a test. The harness has to recognise the request and authorise the action. A model that prints a convincing-looking tool call as ordinary text can leave the file untouched. Aider offers a useful alternative for a small, named set of files. Its search/replace and whole-file formats let a model propose edits in text. The model still needs to reproduce the relevant source accurately. Aider edit formats
A case: the first unattended run of an earlier build of the agent engine went off track because its file-listing tool showed a 50 MB executable the same way as a directory. The fix landed the same day: sizes, binary detection and error messages that name the next step. The hardening work that followed, in July 2026, found the build’s tools working well on Gemini and degrading on other models, and found every mature agent it read selecting, tuning or repairing its tools per model. A related rule from the same build: with no tools bound, strip the instructions that assume tools, because a model told about tools it lacks will narrate tool calls that never happened.
2. How much of the conversation survives the next turn. Instructions, tool descriptions, retrieved files, recent messages and room for a reply all draw on the context window. In Ollama’s chat path, when truncation is enabled, older messages can fall out while system messages and the latest turn are retained. A test failure pasted early in a conversation can disappear from the model’s input while still being visible in the chat interface. Aider estimates the input and requests space for it plus about 8,000 tokens for the reply. That is useful when the default is too small. The request still has to fit the model and hardware. Where a client declares its own context limit, align it with the window the server actually loaded. Ollama chat prompt handling · Aider’s Ollama settings
3. How much work happens before the first token. A long tool list and several source files can take longer to process than the answer takes to generate. Cline offers Use Compact Prompt for local models. A stable system prompt can also let the engine reuse work across turns. That makes prompt length and cache reuse worth checking separately. Cline’s Ollama settings
Measured: a long prompt costs time on every turn only if the runner has to read it again from scratch. In tests of an earlier version of the inference daemon in Contenox Runtime on a laptop GPU with 6 GB, a stable prefix of about 9,000 tokens, roughly the size of a heavy harness’s instructions and tool list, took 1.77 s to process cold and 0.03 s with its cache kept warm. Any change near the top of the prompt, such as a timestamp or a reordered tool list, broke the match and paid the full cold cost again. A harness that keeps its prompt stable from turn to turn is much cheaper on local hardware than its size suggests; one that rewrites the top every turn is not.
Ollama with Claude Code vs OpenCode#
Both clients can use an Ollama model. Their APIs and setup differ.
| Claude Code | OpenCode | |
|---|---|---|
| Setup | ollama launch claude |
Select an installed Ollama model with /models, or use ollama launch opencode |
| API | Ollama’s Anthropic-compatible API | Ollama’s OpenAI-compatible API |
| Who supports it | Ollama documents it; Anthropic doesn’t support Claude Code with non-Claude models | Both OpenCode and Ollama document it |
| Integration limits | Ollama reports token usage. Its Anthropic API lacks explicit cache controls and the token-counting endpoint. Forcing a specific tool or disabling tools is unsupported. Hosted web search is limited. Compatibility details | Tool-call parsing depends on the model and chat template |
| Context control | Set it in Ollama | Set it in Ollama and align any explicit OpenCode model limit |
| The trap | Base URLs in Claude Code’s settings files override your shell variables; check with /status |
Embedding-only models are excluded from OpenCode’s Ollama chat-model picker |
Claude Code suits teams that already use its subagents, file edits and permission flow. OpenCode exposes per-model configuration and can switch between local and hosted providers. For either client, a successful first reply only establishes that the endpoint works. A file read followed by an edit exercises the model’s tool support. Ollama with Claude Code · Ollama with OpenCode
Setup for each harness#
Claude Code
ollama launch claude --model qwen3.8:27b
By hand: ANTHROPIC_BASE_URL=http://localhost:11434, ANTHROPIC_AUTH_TOKEN=ollama and ANTHROPIC_API_KEY="", then claude --model <tag>. Steps per OS: Ollama.
Codex CLI
ollama launch codex
Or codex --oss -m qwen3.8:27b. Inside Codex, /model switches between your tool-capable Ollama models. ollama launch codex --restore removes what the launcher set up.
OpenCode
ollama launch opencode
OpenCode 2 also discovers locally installed completion models on the default Ollama server. Start opencode and select the model in /models. OpenCode with local models
Aider maintenance and model support#
Aider is a good fit for a focused edit when a model follows text instructions reliably but struggles with structured tool calls. For example, the model can replace a named function in two supplied files and leave a Git diff for review. This recommendation depends on the model’s editing behaviour. The memory printed on the GPU box cannot predict it.
Maintenance check, 28 November 2026. The latest commit on Aider’s default branch, main, was on 22 May 2026. It merged an update to the list of Anthropic models. GitHub still listed the repository as unarchived. The latest Python package was aider-chat 0.86.2, published 12 February 2026. GitHub’s latest release entry was v0.86.0, dated 9 August 2025. For an existing installation that already edits reliably, that distinction may have little immediate effect. For a new installation that depends on current model templates or provider changes, six months without a merge on the default branch is material. Latest main-branch commit at review · Branch activity · Python package · GitHub release
Aider setup
python -m pip install aider-install
aider-install
Then in PowerShell, setx OLLAMA_API_BASE http://127.0.0.1:11434 and open a new terminal; on macOS or Linux, export OLLAMA_API_BASE=http://127.0.0.1:11434. In your project:
aider --model ollama_chat/qwen3.5:9b
Aider recommends the ollama_chat/ prefix for its chat integration. Aider setup for Ollama
Goose. On desktop, open Settings → Models → Configure providers and select Ollama. In the CLI, run goose configure and choose Ollama. Select a downloaded model with tool support for file edits and shell commands. If Ollama runs elsewhere, set OLLAMA_HOST to that server. Goose provider setup
Cline: in Cline’s settings in VS Code, pick Ollama, keep http://localhost:11434, choose a model, then enable Use Compact Prompt under Features.
Existing Continue installations. Continue has joined Cursor. If you are maintaining its open-source editor extension, the Ollama entry uses provider: ollama in config.yaml. For a new installation, use one of the maintained routes above. Continue announcement
DeepSeek Harness
ollama launch dsh --model deepseek-v4.1-flash:cloud
Ollama installs it if needed (it requires Node.js). Its web search needs Ollama cloud access, so run ollama signin first. DeepSeek marks the harness as a developer preview, with breaking changes ahead.
Which harness for my hardware?#
Ollama starts with a 4,096-token context window on both a single 8 GiB GPU and a single 16 GiB GPU when no model, client or operator override is in effect. The extra memory on the 16 GiB card still matters. It can hold more model layers, a larger cache, or both. Ollama’s documented tiers are 4K below 24 GiB, 32K in the 24 GiB class and 256K in the 48 GiB class and above. In v0.40.19 the server adds the visible GPUs’ reported VRAM after configured overhead, with cutoffs at 23 and 47 GiB to select the higher tiers. A multi-GPU machine can therefore start with a different window from a single card of the same size. Ollama context guide · Default selection in v0.40.19
| Hardware or service | What that means for a coding session |
|---|---|
| Single 8–12 GiB GPU | Start with one model and one request. A 4B-class model leaves more room for source files and tool results than a larger model at similar weight precision. |
| Single 16 GiB GPU | It starts at the same 4K default. A tool-capable 9B model is one candidate to try with a longer window. Check the actual split after loading it. |
| 24 or 48 GiB GPU class | The larger default helps with repository context. A 27B model at higher weight precision can still consume much of the card. Check the window for the exact model tag. |
| Ollama Cloud | A hosted model runs on the provider’s hardware. The local card size does not set its context window. |
What happens when the weights fit but the conversation grows?#
Consider an 8 GiB card running a 4-bit model. Four bits describes how the weights are stored. Each token in the conversation also needs working memory, including a KV cache that lets generation reuse earlier computations. That cache has its own precision. The GPU also needs room for computation, and a display or another application may already occupy some VRAM. A model that runs entirely on the GPU for a short prompt can need a CPU/GPU split with a longer window. The CPU portion uses system RAM and can slow generation. With insufficient usable memory, loading can fail. For eligible automatic settings, Ollama’s llama-server load path can retry once at a lower context after an out-of-memory error. An explicitly requested window does not get that particular automatic reduction. Ollama memory and offload FAQ · Scheduler retry conditions
Ollama recommends roughly 64K tokens for coding agents. A single-function edit may need much less, while an integration can have its own minimum. Ollama’s OpenCode guide, for example, calls for 64K or more. The desktop context slider, the server’s OLLAMA_CONTEXT_LENGTH setting and a client’s per-request num_ctx can change the requested window. On supported backends, Flash Attention can reduce memory use. With it enabled, OLLAMA_KV_CACHE_TYPE=q8_0 uses roughly half the cache memory of the default f16. Model weights still occupy the same space. More aggressive cache quantisation can affect output quality. Parallel requests introduce another cost. Two slots at 16K need cache capacity for roughly 32K tokens between them. Context settings · Ollama with OpenCode · Cache precision and parallel requests
On a machine with two cards, Ollama prefers a single GPU if the model fits there. Otherwise it can spread the model across the available GPUs. Two 8 GiB cards and one 16 GiB card therefore have different placement and transfer costs. On a laptop with integrated graphics, the GPU can share physical memory with the CPU. Adding the reported graphics memory to system RAM would count some of that memory twice. The table above describes single discrete cards. Ollama’s multi-GPU loading policy
How to read an Ollama run on a small GPU#
After sending a representative coding request, run ollama ps while the model is loaded. CONTEXT shows the allocated window. PROCESSOR shows placement. A CPU/GPU split means some model data is in system memory. 100% GPU means the whole model is loaded on the GPU. Use timing measurements to see how quickly the model actually runs. ollama list shows downloaded models on disk, so it answers a different question. Ollama CLI reference · Processor percentages
| Observation | What to change or check |
|---|---|
| A short edit works, but later turns lose the original error message. | Compare the configured client limit with the loaded context. Remove stale tool output, supply the exact failing test again, or increase the window and recheck placement. |
| A larger window introduces a CPU/GPU split and generation slows. | Repeat the same task with a smaller model, a smaller window or an appropriate cache precision. Compare the resulting diff as well as speed. |
| The first request is slow and an immediate repeat is fast. | Separate model loading from prompt processing. Ollama’s API reports load_duration, prompt_eval_duration and eval_duration. The last measures generation. |
| Two simultaneous tasks fail or queue although either works alone. | Repeat with a single request. Check other resident models with ollama ps. Ollama can queue work until enough memory becomes available. |
For a reproducible check in the Ollama terminal, start an installed model with ollama run MODEL, replace MODEL with its exact tag, and enter /set parameter num_ctx 8192. Send the same failing test and source excerpt twice. While the model is loaded, read ollama ps in a second terminal. Repeat with a larger context only if the job needs it. Keeping the model, input and number of simultaneous requests fixed makes a change in placement or response time interpretable. Ollama CLI · Context parameter
Those observations are more useful for choosing a harness than a GPU-size ranking. Aider’s text-edit format can suit a short change. A multi-step coding agent needs a model that can keep the task in context, issue a valid tool call and use its result on the next turn. For cloud models the provider supplies the inference hardware, and the service’s context and data-handling terms apply. Ollama API timing fields · Models for coding · Diagnose slow local inference
Contenox Harness#
Contenox Harness is a desktop workbench for coding agents. Contenox Runtime handles project tools and checks permissions before actions such as reading a file, editing it or running a command. Backends → Providers → Ollama connects that workbench to a local Ollama server. On this route Ollama loads the model, allocates the context and handles GPU placement. Ollama Cloud is a separate hosted route. Connect Ollama · Project tools and permissions
Native Local AI runs inference through Contenox’s own model service, modeld. On Windows x64, Use local AI → Detect my hardware shows the available memory and recommends a model to download. This option works with Ollama already installed. The native automatic agent setup looks for a model suited to multi-step tool use and estimates whether at least 32,768 tokens of working context can stay resident after weights and runtime allowances. At load time the worker uses the actual free memory, model architecture and cache settings to decide the GPU layer count and context it can serve. Local AI setup · Contenox model selector · Native GPU placement
What the Contenox selector chose at 8 and 16 GiB#
The opening comparison uses the native llama.cpp backend and the curated Contenox catalogue, with models from all regions eligible. The selector was run twice per memory budget. The first run used f16, a 16-bit context cache. The second used q8_0, an 8-bit cache that leaves more memory for model weights. Each run used 80% of nominal GPU memory, matching the selector tests. These runs exercised the selection code. Actual allocation is established when the worker opens a session on the target GPU. Selector test conditions
On the 16 GiB scenario the smaller cache made room for a larger eligible model. The selector chose the 14B model and still cleared its working-context threshold. That explains why the estimated token count went down. Ollama’s 4,096-token default and these estimates answer different questions. The former is a starting configuration for a selected model. The latter are the result of choosing a model and budget together for agent work. Model selection order
Manage local models · Download Contenox Harness

Related guides#
What is an AI coding harness?: the term, and what a harness does around the modelWhat is an AI coding harness? Harness vs agent vs modelWhat is an AI coding harness? The program around the model: loop, tools, context, permissions. How it differs from the model, and why it changes the results.
AI coding harness comparison: the harnesses compared beyond OllamaAI coding harness comparison: 16 agents, every cell checkedAI coding harness comparison for November 2026: license, models, subscription sign-in, local models, Windows, permissions and sandbox for 16 coding agents.
Open-source AI coding agents: the open options in detailOpen source AI coding agents in 2026: every license checkedEvery notable open source AI coding agent with its license, interface and models, checked November 2026, plus what open source does and doesn't get you.
Best Ollama models for coding: picks per GPU sizeBest Ollama models for coding, by VRAMThe best Ollama model for coding at 8, 12, 16, 24 and 48+ GB VRAM and on Ollama Cloud: exact tags, tool support, context memory and the benchmarks behind them.
OpenCode with local models: the full config and the context fixOpenCode with local models: Ollama, LM Studio, llama.cpp, vLLMSet up an OpenCode local model: automatic discovery for Ollama, LM Studio and vLLM, plus a llama.cpp configuration, context limits and tool calls.
Choose a coding modelHow to compare AI coding models on your own codebaseCompare AI coding models on five tasks from your repository. Score each run on passing tests, unnecessary edits, elapsed time and cost per finished task.
Coding benchmarksAI coding agent leaderboards and benchmarks, explainedEvery AI coding agent leaderboard worth checking in 2026: what each measures, who runs it, why the scores mislead, and how to benchmark agents on your own repo.
Local vs cloud AILocal AI vs cloud AI for coding: which should you use?Local AI vs cloud AI for coding: compare privacy, offline work, hardware and cost, then try the same task with both before choosing where your model runs.
Which AI provider?Which AI provider for coding agents? A decision guideWhich AI provider for coding agents: subscription or API key, cloud account or local, and which providers work in Claude Code, Codex CLI and OpenCode.