Roo Code Ollama: local models in Cline and Aider, an honest look
We connect Ollama to Roo Code, Cline, Aider and OpenCode per each tool's documentation, cover the limits and show when it is simpler to return to a cloud API.
6 min · · агенты · models
Running a coding agent on a model from your own computer is tempting: the code does not leave your machine and there are no tokens to pay for. Note up front that the Roo Code extension itself was shut down on May 15, 2026; details below. Setting it up is easy, but getting the agent to work well means dealing with a few unexpected limits. This article, based on the tools' documentation, covers how to connect Ollama in Roo Code (the "roo code ollama" query), Cline, Aider and OpenCode, where it runs into trouble in practice, and when it is more sensible to return to a cloud API.
What an agent needs from a local model
An agent has different requirements from a plain chat. Three of them decide everything.
- Tool calling. An agent reads and edits files by calling functions. If the model does not support them, some tools simply will not work. The OpenCode documentation advises, when there are problems, to pick a model with good tool-calling support, for example a Qwen-Coder or DeepSeek-Coder variant.
- Context. The agent sends the model system instructions, a file list, file contents and step history. A few thousand tokens run out instantly. Per the Ollama documentation, the default context length depends on VRAM: under 24 GiB gives 4k tokens, 24 to 48 GiB gives 32k, 48 GiB and more gives 256k, and for agents and coding tools the documentation advises at least 64,000.
- Memory. The longer the context, the more memory it takes.
ollama psshows whether the model fit entirely on the GPU or partly moved to the CPU, which slows answers a lot.
Start by setting the context in Ollama itself, then configure the tools. The simplest way: OLLAMA_CONTEXT_LENGTH=65536 ollama serve or a Modelfile:
FROM <base-model-name>
PARAMETER num_ctx 32768ollama create my-coder -f ModelfileChoose the value for your memory: the Roo Code documentation gives guide values of 16384 for about 8 GB of VRAM, 32768 for about 16 GB and 65536 for 24 GB and more.
Roo Code Ollama: setup per the documentation
A warning: according to a notice in the Roo Code documentation, the extension was shut down on May 15, 2026, and the GitHub repository has been archived. As alternatives the documentation names ZooCode, a community fork, and Cline. The description below comes from the Roo Code documentation and applies to an already installed copy; for the fork, check menu items against its own documentation.
The procedure per the Roo Code documentation:
- Install Ollama and make sure it is running (
ollama serve). - Download a model:
ollama pull <model-name>. - In the Roo Code settings (gear icon) choose API Provider: ollama.
- Enter the model name or the name of your saved copy with the right
num_ctx. - The default base address is
http://localhost:11434; change it only if Ollama runs on another machine.
By default Roo Code takes the context length from the Modelfile, so you do not set it separately in the extension. The troubleshooting section describes a common failure: the first request crashes on memory because on a cold start Ollama allocated more context than you expected. The fix: start the model beforehand (ollama run <model>) and pin num_ctx in the Modelfile.
Cline: Ollama and LM Studio
The Cline documentation describes both options in its local models section.
- Ollama: in the Cline settings choose the Ollama provider, Base URL
http://localhost:11434, and pick the model from the dropdown (it must already be downloaded). - LM Studio: start the server on the Developer tab (by default
http://localhost:1234), load a model, choose the LM Studio provider in Cline and leave the Base URL as is. This answers the "cline lm studio" query.
The Cline documentation's recommendations for local work: enable Use Compact Prompt in the Features section of settings, keep tasks narrow (less context, faster replies) and start a new task when the context grows. It also gives a RAM guide table: 16 to 32 GB suits small or quantized models, 32 to 64 GB mid-size models, 64 GB and more larger models and bigger context.
Aider and Ollama
For the "aider ollama" query, the Aider documentation gives this order:
export OLLAMA_API_BASE=http://127.0.0.1:11434
ollama pull <model-name>
OLLAMA_CONTEXT_LENGTH=8192 ollama serve # in a separate terminal window
cd /path/to/project
aider --model ollama_chat/<model-name>The documentation recommends the ollama_chat/ prefix over ollama/. It also warns that Ollama silently discards whatever did not fit in the context window, so the agent can fail to "see" part of the data with no error. By default Aider sets the window large enough for each request plus 8k tokens for the reply. A fixed value is set in the .aider.model.settings.yml file:
- name: ollama/<model-name>
extra_params:
num_ctx: 65536The Aider documentation mentions a 2k default for Ollama, while the Ollama documentation describes a value based on VRAM. Check your version with ollama ps, the CONTEXT column.
OpenCode and Ollama
For the "opencode ollama" query, the OpenCode documentation describes a local server as a custom provider in opencode.json:
{
"$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>": { "name": "Local model" } }
}
}
}If tool calls do not work, the documentation advises raising num_ctx in Ollama to roughly 16 to 32 thousand. For LM Studio the config is similar, with the address changed to http://127.0.0.1:1234/v1.
When to switch to an API
Signs that running locally is getting in the way: the agent loses the thread after a few files, tool calls break, you wait a minute for each reply, memory is taken and nothing else will open. Switching takes a couple of lines:
- Cline: the OpenAI Compatible provider, Base URL
https://api.zukko.pro/v1, keyfetch_..., modelclaude-sonnet-5-5. Details are in the VS Code extensions documentation. - Aider: per the Aider documentation, OpenAI-compatible APIs need variables and a model prefix:
export OPENAI_API_BASE=https://api.zukko.pro/v1
export OPENAI_API_KEY=fetch_your_key
aider --model openai/claude-sonnet-5-5- OpenCode: the same provider with
@ai-sdk/openai-compatible,baseURLset tohttps://api.zukko.pro/v1and"apiKey": "{env:ZUKKO_API_KEY}"inoptions; get the key itself in the dashboard.
A calculation at prices as of October 18, 2026. An Aider or Cline session: 20 requests, each with 25,000 input tokens and 1,000 output tokens, with no cache.
deepseek-v4.1-flash(0.013 / 0.038): 25,000 × 0.013 + 1,000 × 0.038 = 325 + 38 = 363 micro-dollars per request, 363 × 20 = 7,260, about $0.007 per session.glm-5.3-flash(0.04 / 0.04): 25,000 × 0.04 + 1,000 × 0.04 = 1,040, 1,040 × 20 = 20,800, about $0.021.claude-sonnet-5-5(0.4 / 2): 25,000 × 0.4 + 1,000 × 2 = 12,000, 12,000 × 20 = 240,000, $0.24.
Compare that with your electricity and waiting time. For constant heavy agent work, Claude and GPT offer a context of up to 1M tokens (model table; GLM has 128K). Which model to take is decided by testing on your project. Model list and prices: GET https://api.zukko.pro/v1/models. Payment: SBP (the payment page adds an 8.5% fee on top), cryptocurrency or MasterCard. Cline and Aider setups with a cloud key are covered separately: Cline, aider.
FAQ
Can I keep a local and a cloud model together?
Yes. In Cline, for example, you can set different models for Plan and Act, and in Aider you pick the model with the --model flag at launch. Keep private tasks local and send heavy ones to the cloud.
Why does the agent "forget" files?
Often the Ollama context is smaller than you think, and the excess is silently discarded. Check ollama ps and set num_ctx explicitly.
Which local model writes the best code?
We do not rate open models' quality. Take variants with tool calling support and test on a small real task.
Does a local server need a key?
Usually not. If a tool requires the field, enter any string; Ollama accepts the key without checking.
zukko
Pay 25×
less
for Claude Code & ChatGPT
One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.
Related articles
- AI agent vs AI assistant: the difference and what to pick for a taskA model answers, an assistant remembers the dialogue, an agent takes steps with tools on its own. The differences by example, and how to decide what your task needs.
- opencode agents: setting up roles, models and toolsA custom agent in opencode is a role, a model and a set of permissions. A working config where a cheap model handles routine work and a stronger one edits code.
- Plan mode in Claude Code: plan first, then edit the codeIn plan mode Claude Code reads your code and proposes a plan but edits nothing until you agree. How to enable it, use it and what it costs.
- xAI Grok API: Connecting Grok 4.7, Price and the 256K ContextHow to call grok-4.7 through an OpenAI-compatible API, what to do about the 256K context limit and what typical requests cost. Plus a comparison with Grok 4.6.