Terminal Coding Agents on Local Models: OpenCode, Qwen Code, Aider & Friends

Written by Jakub Rusinowski · Last updated 2026-08-04 · Hardware figures computed by our VRAM engine

The terminal is where open-source coding agents caught up fastest. OpenCode, Qwen Code and Aider are all model-agnostic and all speak the OpenAI-compatible API that Ollama, LM Studio, llama.cpp and vLLM expose — so pointing them at your own GPU is a base-URL and a model name. What differs is harness weight: Aider is the lightest and survives a 16K window; the newer agents do more and want 24 GB and up.

Two years ago the good coding agents were closed products tied to one provider. In 2026 the strongest ones in the terminal are open source and provider-agnostic by design — you configure an endpoint, and the agent does not care whether it is a frontier API or llama-server on the box under your desk. OpenCode in particular grew into the de-facto open answer to the closed terminal agents, MIT-licensed and able to reach a long list of providers including local ones.

For local-first developers this is the important shift. You are no longer choosing between "good agent, someone else's model" and "your model, mediocre tooling." You can run a well-engineered harness on weights you own. The remaining constraint is the one this whole hub keeps returning to: the heavier the harness, the more window it needs before it starts working.

The four that matter locally

AgentShapeLocal endpointWindow it wantsBest for
AiderTerminal, git-native, diff-based editsOllama, any OpenAI-compatible8–16K workableSmall models and small cards. The lightest real harness
OpenCodeFull terminal agent, TUI, MITAny OpenAI-compatible provider, Ollama included32K comfortableTerminal-first work, swapping models per task
Qwen CodeTerminal agent tuned to the Qwen coder lineOpenAI-compatible endpoints and local Ollama32K comfortableRunning the Qwen3-Coder family the way it was trained to be driven
Cline *(not terminal, listed for contrast)*VS Code agentOllama, LM Studio32K+Editor-native work — see the Cline guide

The pattern is consistent: the agents that do the most assume the most context. On 16 GB, Aider's compact repo map and search/replace edit formats mean far more of the window is your code and far less is scaffolding. On 24 GB and up, the fuller agents pay off — their planning, todo tracking and multi-file editing genuinely reduce the number of turns.

Pointing an agent at your own GPU

The mechanics are the same everywhere: an OpenAI-compatible base URL, a model name, and a dummy API key for clients that insist on one.

# 1. Serve a model with a context window that fits an agent's prompt
cat > Modelfile <<'EOF'
FROM qwen3.6:27b
PARAMETER num_ctx 32768
EOF
ollama create qwen3.6:27b-32k -f Modelfile
ollama serve            # OpenAI-compatible at http://localhost:11434/v1

# 2. The environment most CLI agents read
export OPENAI_BASE_URL=http://localhost:11434/v1
export OPENAI_API_KEY=local            # ignored, but often required to be set

# 3. Aider, explicitly
aider --model ollama_chat/qwen3.6:27b-32k

# llama.cpp instead of Ollama — same interface, finer control
llama-server -m qwen3-coder-8b-q4_k_m.gguf --port 8080 --ctx-size 16384 \
  --jinja        # use the GGUF's chat template, needed for tool calls

Three things to get right, in order of how often they are wrong:

1. Context window. The default is too small for any agent's system prompt plus a file. This is the single most common cause of "the agent ignores instructions" — see context engineering. 2. Tool-call support. If the agent uses function calling, the served model needs a chat template that supports it (--jinja on llama-server; an agentic tune rather than a base chat model). Otherwise pick an agent that uses diff formats instead (tool calling). 3. VRAM headroom for the cache. Weights plus 32K of KV cache, not weights alone. Check it with the calculator before you discover it mid-task.

Which model to serve a terminal agent

Q4_K_M weights from the site’s compute engine — add KV cache for the context you configured. Agent prompts are large; do not size on weights alone.

ModelVRAM (Q4)Runs onContextLicense
Qwen3-Coder 8B
8 GB — Aider tier — Pairs with the lightest harness and tightly scoped tasks. Long context for its size.
ollama pull qwen3-coder:8b
5.6 GB8 GB GPU (RTX 3060/4060)
Mac: 16 GB unified
125KApache-2.0
Devstral-2 22B
16 GB — first agentic tier — Agent-tuned; the best value for terminal agents that expect tool calls.
ollama pull devstral:22b
14.1 GB16 GB GPU (RTX 4060 Ti 16GB / 5060 Ti)
Mac: 24 GB unified
125KApache-2.0
Qwen 3.6 27B
24 GB — daily driver — Where a full terminal agent stops feeling like a compromise.
ollama pull qwen3.6:27b
17.6 GB24 GB GPU (RTX 3090/4090)
Mac: 24 GB unified
256KApache-2.0
Qwen3-Coder 80B-A3B (MoE)
Workstation / 96 GB+ Mac — MoE decode speed makes long agent sessions practical at high quality.
ollama pull qwen3-coder:80b-a3b-q4
49.1 GB2×48 GB GPUs / big unified memory
Mac: 96 GB unified
125KApache-2.0

Terminal or editor?

Not a rivalry — most people end up with both, and the split follows the task.

Terminal agents own work that is naturally command-shaped: repo-wide refactors, migrations, "make the suite green," anything you want to run in a worktree and review as a diff. They compose with everything else you have — pipe output in, run them over SSH, wrap them in a shell loop. That last property is what makes them the natural host for loop engineering.

Editor agents own work where seeing the file matters: exploratory changes, UI work, anything where you want inline diffs and the language server's opinion beside you.

Autocomplete is a separate job with a separate model — a small FIM-tuned model answering in milliseconds, running alongside whichever agent you use. Full breakdown in the tool matrix.

Honest limits on local hardware

What you should expect, so you configure around it rather than concluding the tooling is broken:

No hardware? Rent the GPU first

Want to know whether a heavier terminal agent is worth a hardware upgrade? Rent a 48 GB GPU for an evening, serve the bigger model, and run your own repo through it before spending anything.

Full list on the cloud AI directory.

Frequently asked questions

Can OpenCode run on a local model?
Yes. OpenCode is provider-agnostic and reaches a long list of providers including local Ollama, so pointing it at your own GPU is a base-URL and model-name change. It is a fuller harness than Aider, which means a larger system prompt and more tools — budget a 32K served context and a 24 GB-class card for it to feel comfortable.
What is the best terminal coding agent for a local LLM?
It depends on your VRAM more than your taste. Under 16 GB, Aider: its compact repo map and diff-based edit formats leave far more of a small window for your code. At 24 GB and up, OpenCode or Qwen Code — their planning and multi-file editing genuinely reduce turn counts once you can afford the prompt overhead.
How do I point a CLI coding agent at Ollama?
Serve a model with an explicitly raised context window, then set OPENAI_BASE_URL to http://localhost:11434/v1 and OPENAI_API_KEY to any non-empty value. Aider takes it directly with --model ollama_chat/<tag>. The step people miss is the context window: the default truncates an agent’s system prompt, which looks like the model ignoring instructions.
Do terminal agents need tool-calling support in the model?
The function-calling ones do — the served model needs a chat template with tool support (pass --jinja on llama-server, and prefer an agentic or coder tune over a base chat model). Aider is the exception: it asks for diffs and search/replace blocks rather than JSON tool calls, which is why it tolerates weaker models.
Is a terminal agent better than a VS Code agent for local models?
For loop-shaped work, yes — terminal agents compose with shell scripts, git worktrees and CI, which is what makes automated verify-and-retry loops practical. Editor agents win where seeing the file matters: exploratory edits, UI work, anything you want reviewed inline. Most local setups run a terminal agent, an editor agent, and a small autocomplete model for different jobs.

Keep going