← Back to Blog

Run a local Ollama model as a Coral agent with Pi

Can a local open-weights model run inside Coral as a real coding agent—reading files, editing code, running tests, and posting results back to the team's message board—without sending a single token to a cloud API?

We ran a controlled trial on a 16 GB GPU workstation (Windows 11 Pro for Workstations with an NVIDIA RTX A4000 16 GB, about 0.9 GB in use at idle) to find out. Because Coral supports pi (@mariozechner/pi-coding-agent) as a first-class agent CLI, and pi speaks OpenAI-compatible completions to a local Ollama server, you can point a Coral seat at an Ollama model running on 127.0.0.1:11434.

We tested two popular open coding models at a 32K context window against the same small coding + board-reporting task:

Here is the honest result—the exact setup, the speed and VRAM numbers, why the 14B model failed completely on tool use while the 30B MoE model finished the job at ~37 tokens/sec, and the rough edges we hit (and are improving) along the way.

The short version

If you want to try a local model in Coral on a 16 GB GPU today:

  1. Use qwen3-coder:30b, not qwen2.5-coder:14b:
    • qwen2.5-coder:14b cannot call tools through Ollama: When given tools (bash, edit, etc.), Ollama returned finish_reason: stop and tool_calls: null, dumping raw JSON ({"name": "edit", ...}, {"name": "bash", ...}) into the chat text instead of invoking any tool. No file was edited, no test ran, and its proposed test assertion was wrong (char_count('a b c') == 5 instead of 3).
    • qwen3-coder:30b completed the whole task: It returned structured tool_calls, added the function and unit tests, ran python -m unittest -v (5 tests OK), and posted the result to the Coral message board (@all char_count added; python -m unittest: 5 tests OK)—after two operator nudges over an ~8-minute session.
  2. Speed is genuinely usable once warm:
    • Both models generated at ~35–37 tokens/sec warm (35.0 tok/s for 14B; 36.9 tok/s for 30B MoE) with a 0.05–0.06 s warm time-to-first-token.
    • Even though qwen3-coder:30b at 32K context takes 22 GB in memory (spilling 33% to CPU / 67% on GPU, using 15.3 GB of the 16 GB GPU), its 3B-active MoE architecture still generates slightly faster than the dense 14B model.
    • Cold loads take ~28–59 seconds (and Ollama unloads idle models after 5 minutes by default), so the first reply after a pause waits on model load.
  3. Local models still need human nudging—and we found integration rough edges to smooth out:
    • Even qwen3-coder:30b stopped early once after inspecting files, twice tried to call a non-existent tool named coral-board post instead of running coral-board post through bash, and initially ran echo instead of posting.
    • Our trial also surfaced a few integration rough edges around pi model discovery, session resuming, and usage display —all fixed in Coral v2.1.19 and later (see What broke in the integration).

How we set up Ollama, pi and Coral

Everything in the trial ran unprivileged inside a single folder with no system-wide services or firewall changes.

Versions tested

ComponentVersion
OS & GPUWindows 11 Pro for Workstations, NVIDIA RTX A4000 16 GB (~0.9 GB used at idle)
Ollama0.40.18 (standalone Windows zip, verified against release sha256sum.txt)
Pi CLI@mariozechner/pi-coding-agent 0.73.1 from npm
Node.js26.13.0
CoralAn earlier Coral build
Modelsqwen2.5-coder:14b (9.0 GB) and qwen3-coder:30b (18 GB)

Step 1: Run Ollama on loopback with a 32K context window

Coding agents send several thousand tokens of system and tool instructions on the very first turn (in our trial, pi + Coral's board instructions + the task prompt totaled ~6.1k tokens on turn 1). Ollama's default short context window will truncate agent instructions unless you raise OLLAMA_CONTEXT_LENGTH:

$env:OLLAMA_HOST = "127.0.0.1:11434"
$env:OLLAMA_MODELS = ".\models"
$env:OLLAMA_CONTEXT_LENGTH = "32768"
ollama serve

In a second shell, pull the model:

ollama pull qwen3-coder:30b

When the model loads, ollama ps confirms CONTEXT 32768.

Step 2: Configure pi (models.json) to talk to Ollama

Install @mariozechner/pi-coding-agent and point PI_CODING_AGENT_DIR at your pi config folder (or use the default ~/.pi/agent). Create models.json:

{
  "providers": {
    "ollama": {
      "baseUrl": "http://127.0.0.1:11434/v1",
      "api": "openai-completions",
      "apiKey": "ollama",
      "compat": {
        "supportsDeveloperRole": false,
        "supportsReasoningEffort": false
      },
      "models": [
        { "id": "qwen2.5-coder:14b", "contextWindow": 32768, "maxTokens": 8192 },
        { "id": "qwen3-coder:30b", "contextWindow": 32768, "maxTokens": 8192 }
      ]
    }
  }
}

Two details that save debugging time:

Verify that pi sees both models:

pi --list-models

Step 3: Point Coral at pi and launch the agent

In Coral's Settings > Providers, set cli_path_pi to your pi binary if it isn't already on Coral's PATH.

When you launch a pi session in Coral with model ollama/qwen3-coder:30b, Coral starts pi with its board extension wired up automatically:

pi --model ollama/qwen3-coder:30b --session-dir <data>/pi-sessions/<id> -e <coral extension>

We gave both models the exact same repository (textkit.py with an existing word_count function and test_textkit.py with 2 unit tests) and the same prompt:

"In textkit.py add a function char_count(text) that returns the number of non-whitespace characters. Add a test for it in test_textkit.py. Run: python -m unittest -v. Then post the test result on the board with coral-board post."

Speed and GPU memory: 14B dense vs. 30B MoE on 16 GB

We measured both models directly through Ollama's timing metrics (/api/generate, streaming, temperature 0, identical coding prompt) as well as inside pi at a 32,768-token context length:

Metricqwen2.5-coder:14b (dense)qwen3-coder:30b (MoE, 3B active)
Disk size9.0 GB18 GB
Memory size loaded at 32K context15 GB22 GB
CPU / GPU split (ollama ps)5% CPU / 95% GPU33% CPU / 67% GPU
GPU VRAM used (nvidia-smi)15,350 of 16,376 MiB (~15.3 GB)15,343 of 16,376 MiB (~15.3 GB)
Model load time29.0 s27.6 s
First token (cold)58.6 s28.6 s
First token (warm)0.06 s0.05 s
Generation speed (warm)35.0 tok/s36.9 tok/s
Prompt processing (warm)~1,600 tok/s~900 tok/s

What surprised us most:

Model by model: why 14B failed and how 30B finished the job

qwen2.5-coder:14b: Failed (no structured tool calls)

In an agent CLI like pi, a model cannot change files or run tests by printing code blocks—it has to emit structured OpenAI tool_calls for edit, bash, and file-reading tools.

qwen2.5-coder:14b never called a single tool:

To confirm whether the bug was in Coral, pi, or Ollama, we queried Ollama's /v1/chat/completions endpoint directly with a bash tool definition. Ollama returned finish_reason: stop, tool_calls: null, and the raw JSON inside content. Because Ollama does not parse qwen2.5-coder:14b's output into structured tool_calls, neither pi nor Coral can execute them.

Coral Chat view for a demo session using the model qwen2.5-coder:14b through pi, printing raw JSON for an edit call and a bash call as text instead of running them.
qwen2.5-coder:14b in Coral’s Chat view prints raw {"name": "edit", ...} and {"name": "bash", ...} JSON as text instead of invoking tools.
Coral Terminal view of the same qwen2.5-coder:14b session, showing the pi footer with token usage and the 32K context window.
The same qwen2.5-coder:14b session in Coral’s Terminal view, showing pi’s footer with token usage and the 32K context window (17.7%/33k).

qwen3-coder:30b: Finished the task (with two operator nudges)

When we probed qwen3-coder:30b against Ollama's /v1/chat/completions endpoint with the same tool definition, it returned a proper structured tool_calls entry immediately.

Inside Coral, the full run took about 8 minutes from launch to board post, including two short nudges from the operator:

  1. Turn 1 (orientation, then stopped early):
    • Seeing coral-board post in Coral's instructions, the model first tried to invoke a tool literally named coral-board post. pi replied: Tool coral-board post not found.
    • It then used its real tools to run ls and read textkit.py and test_textkit.py.
    • Then it stopped after saying "Let me start by examining…" without making any edits.
  2. Nudge 1 ("Go ahead: make the edits, run the tests, and post the result with the bash tool"):
    • Its first edit tool call failed on a match mismatch; it recovered on its own by rewriting the test file cleanly.
    • It added char_count(text) to textkit.py and added 3 new unit tests to test_textkit.py.
    • It ran python -m unittest -v via bash: 5 tests, OK (which we also verified independently).
    • When it tried to report back, it again called the non-existent coral-board post tool, fell back to running echo "<message>" in bash, and declared the task "completed as requested".
  3. Nudge 2 ("The board did not get your message: echo only prints it. Use the bash tool to run exactly: coral-board post ..."):
    • It ran coral-board post via bash. Coral's CLI validation rejected its first attempt with a helpful error: this post notifies nobody: add @Name, --to, or --task.
    • The model read the error, retried with @all, and posted to the board: @all char_count added; python -m unittest: 5 tests OK.
Coral Chat view for a demo session using qwen3-coder:30b through pi: it edits files, recovers from a failed edit, runs python -m unittest with 5 tests passing, and posts the result.
qwen3-coder:30b in Coral’s Chat view completing the edits, recovering from a failed edit call, running python -m unittest -v (5 tests OK) and posting the result after two operator nudges.
The Board tab of the demo team demo-board in Coral, showing the final post from the local qwen3-coder:30b agent: char_count added; python -m unittest: 5 tests OK.
The team board (demo-board) with the local qwen3-coder:30b agent’s final post: @all char_count added; python -m unittest: 5 tests OK.

One honest code-quality note: qwen3-coder:30b implemented char_count by chaining .replace(' ', '').replace('\t', '').replace('\n', '') rather than using not ch.isspace() or re.sub(r'\s+', '', text). All 5 unit tests passed, but a string containing Windows \r\n line endings (char_count('a\r\nb')) would return 3 instead of 2. Local 30B models can write working code and use tools, but pairing them with a stronger reviewer (or a clear test checklist) still matters.

What you see in the Coral dashboard

Running pi + Ollama inside Coral already integrates cleanly in several places:

What broke in the integration (and what we improved in v2.1.19)

We ran this trial on an earlier Coral build not just to benchmark local models, but to see every rough edge a developer would hit. All of the fixes below are in Coral v2.1.19 and later:

Takeaways: when to use a local model in Coral

A 16 GB workstation GPU is enough to run a real tool-using coding agent inside Coral through pi and Ollama—if you pick a model whose tool calls Ollama supports (qwen3-coder:30b worked; qwen2.5-coder:14b did not) and configure a 32K context window (OLLAMA_CONTEXT_LENGTH=32768).

At ~37 tokens/sec warm, qwen3-coder:30b is fast enough for bounded coding tasks, test writing, and offline experimentation, especially when paired with Coral's board, file-diff view, and human or cross-model review gates to catch when a local model stops early or misses an edge case like \r\n.

Try Coral

Open source. Runs on your own computer.

Download Coral

Keep reading