Coding with DeepSeek, Qwen or local models in a terminal agent
How to run a terminal coding agent on open-weight models such as DeepSeek V4, Qwen and Kimi, hosted or local through Ollama, and what results to expect.
CodeAF is an open-source (Apache 2.0) terminal coding agent by AgentField built for open-weight models: it takes keys for DeepSeek, Qwen, GLM, Kimi and MiniMax, reaches the rest through OpenRouter, and runs local models through Ollama (no key) or any OpenAI-compatible endpoint such as llama.cpp or LM Studio (FAQ). What to expect depends on the model: on DeepSeek V4 Flash, CodeAF in senior-dev mode solved 54.9% of DeepSWE's 113 tasks, first of ten harnesses on that model; a small local model on a laptop will do much less.
At a glance
| Hosted open model (DeepSeek, Qwen, Kimi, GLM) | Local model (Ollama, llama.cpp, LM Studio) | |
|---|---|---|
| How CodeAF connects | A provider key, or OpenRouter | Ollama needs no key; others through an OpenAI-compatible endpoint |
| Where model calls go | The provider you connect | Your machine or your network |
| Cost | Provider's token price | Nothing per call |
| Quality | Strongest sourced results (below) | Varies with model size and hardware |
| Context to check | senior-dev refuses models known to hold 32,768 tokens or fewer | Same rule, so set the runtime's context high enough |
| Keep every seat open-weight | /crew models open | /crew models open |
Set it up
curl -fsSL https://agentfield.ai/get/codeaf | bash
codeafFirst setup starts with a provider chooser; codeaf connect later lists every model service and whether it is connected, and codeaf connect <service> adds one (connections). DeepSeek, GLM, Kimi, MiniMax and Qwen take keys, Ollama needs none, and the Z.ai and Qwen coding plans and Kimi Code connect with a key from the same list (attach a plan).
Then say which model to use, in plain words: "Run this as a task on kimi k3: ..." puts moonshotai/kimi-k3 in the worker seat for that one task (choose the model). To keep it there, /crew pin worker <model>. To keep every seat on open-weight models, the README gives /crew models open.
What results to expect on DeepSeek V4
These are our numbers, from our DeepSWE comparison, and each names its model:
- The comparison. All ten harnesses ran on one model,
deepseek/deepseek-v4-flash-0731through OpenRouter, on the full 113-task DeepSWE set with the official verifiers and 3 hours per task. CodeAF in senior-dev mode solved 62 (54.9%) at 22 cents a task, the most of the ten, and the lowest cost per solved issue (39.9 cents; mini-swe-agent 1.9x, Codex 2.1x, Claude Code 3.4x). - The caveats. It is our comparison, run once. CodeAF used provider-default sampling while the other harnesses sent temperature 1.0 and top-p 0.95. It measures the harness on DeepSeek V4 Flash, not any harness on its home model.
- Later single-harness runs. The same mode solved 88 of 113 (77.9%, exact 95% CI 69.1% to 85.1%) with DeepSeek V4.1 Flash, and 78 (69.0%) with Kimi K3. Those are not a comparison with other harnesses.
senior-dev is the specialist for large changes; type /senior-dev and the brief, and it works alone on its own branch, then runs your build and tests on what it handed in (senior-dev).
Mixing cheap and strong open models
A task is a crew of worker, planner and checker, and each seat can be a different model (Pareto crewing). Left on auto, CodeAF scores the allowed models for each seat on that kind of work and stops where more money stops buying quality. You can also steer by rule: "security fixes in this repo always run on openai/gpt-oss-120b" sends those tasks to that model while other work keeps the usual crew (rules). A 15-minute go vet routine on openai/gpt-oss-120b cost about 8 cents a run in the docs' test (schedules).
Running fully local
Ollama needs no key, and any OpenAI-compatible endpoint works, so model calls stay on your machine and a local model costs nothing per call (FAQ). Two honest limits. First, quality varies with model size and hardware: try a local model on lookups and small edits before handing it a multi-file change, and run large models on a GPU box, which you can drive with codeaf chat --host gpubox (remote machines). Second, context: senior-dev refuses a model known to hold 32,768 tokens or fewer, and assumes 16,384 only when no catalog can be read. For what else leaves the machine, see keeping code in your own infrastructure.
When something else fits better
OpenCode with Ollama starts with one command, ollama launch opencode, and Ollama's docs say OpenCode needs a context length of 64k or higher (Ollama docs). Aider with Ollama runs as aider --model ollama_chat/<model>; Aider notes Ollama's 2k default context window and sizes the window per request so data is not dropped (Aider docs). Choose Aider if you want a pair programmer in one repo. Claude Code can run on DeepSeek by setting ANTHROPIC_BASE_URL to https://api.deepseek.com/anthropic with a DeepSeek key, and DeepSeek's integration list also includes DeepSeek Harness, Codex and OpenCode (DeepSeek docs). Choose that if your team already knows Claude Code and wants DeepSeek prices. For the wider provider picture, see a coding agent for any model.
Questions people ask
Which terminal coding agent can I run with local or open-weight models like DeepSeek or Qwen?
CodeAF is built for them. It connects DeepSeek and Qwen with a key, other open models through OpenRouter, and local models through Ollama with no key or any OpenAI-compatible endpoint such as llama.cpp or LM Studio.
Which coding agent works well with DeepSeek V4?
On DeepSeek V4 Flash, CodeAF in senior-dev mode solved 62 of 113 DeepSWE tasks (54.9%) at 22 cents a task, first of ten harnesses in our comparison on that one model. A later run of the same mode with DeepSeek V4.1 Flash solved 77.9%; that run is not a comparison with other harnesses.
Can I keep every model call on open-weight models?
Yes. /crew models open limits every crew seat to open-weight models, and a rule can send a kind of task to one named open model.
Will a small local model handle big refactors?
Usually not well. Local quality depends on model size and hardware, and senior-dev refuses models known to hold 32,768 tokens or fewer. Use a large model on a GPU box, reached with codeaf chat --host, for big changes.
Is CodeAF only for open models?
No. Claude, GPT and Gemini are available through OpenRouter, and a ChatGPT plan can sign in through Codex. Open models are the design target, not the limit.
Sources
- CodeAF docs: FAQ, connections, attach a plan, choose the model, senior-dev, Pareto crewing, rules, schedules, remote machines, checked 2026-11-21.
- CodeAF README (dev branch) for
/crew models openand provider keys; DeepSWE figures from the DeepSWE method page and our benchmark page. - Ollama: OpenCode, Aider: Ollama, DeepSeek: Claude Code integration, checked 2026-11-21.
Last updated 2026-11-21. Checked against CodeAF v0.8.3 docs and the Ollama, Aider and DeepSeek documentation on that date.