Fine-Tuning a Local 14B Model on Coral’s Agent Tools
In our earlier trial of local Ollama models running inside Coral via pi, the dense qwen2.5-coder:14b model could not drive Coral's agent tools at all: when asked to edit files, run tests, and post to the team board, it printed raw JSON or markdown blocks into chat and made zero structured tool calls (0% clean across 30 held-out runs). Even the larger qwen3-coder:30b Mixture-of-Experts model only reached about 35% clean (33% to 37% across our base benchmark runs), frequently trying to invoke a non-existent tool literally named coral-board post or coral-agent instead of running those commands through pi's bash tool.
That raised an obvious follow-up question: is a 14B open-weights model simply too small to operate a multi-agent CLI toolkit, or does it just need a targeted fine-tune on structured tool calls and Coral's command rules?
To find out, we built an automated Coral-tools harness and ran a small QLoRA fine-tune of qwen2.5-coder:14b (Qwen2.5-Coder-14B-Instruct) on 1,722 locally generated, synthetic tool-call traces, exported the merged model back to GGUF (Q4_K_M, 8.37 GiB) for Ollama, and tested it inside pi against a throwaway Coral server.
On the held-out benchmark, the fine-tuned 14B model jumped from 0% clean to 90% clean (mean score 0.00 → 1.90 out of 2.00), with 30 of 30 runs making valid structured tool calls and 0% forbidden commands. And on a separate 10-task memorization check built from subcommands and flags never seen in training, it reached 40% clean—revealing both genuine generalization and the honest limits of training on mostly scripted templates.
The Short Version
- Held-out Coral tool tasks went from 0% to 90% clean:
- Base
qwen2.5-coder:14b: 0% clean (mean score0.00 / 2.00), 0 of 30 runs with a parsed tool call. Every turn ended withfinish_reason: stopand plain text. - Base
qwen3-coder:30b: ~35% clean (33%/37%across base runs, mean score0.73 / 2.00). In 23 of 30 runs it called tools that do not exist (coral-board read,coral-board task list,coral-board post,coral-agent skills list) instead of callingbash. - Fine-tuned
qwen2.5-coder:14b(Q4_K_Min Ollama): 90% clean (mean score1.90 / 2.00), 30 of 30 runs with a parsed tool call, 0% forbidden commands, averaging 7.9 seconds per task. It beat the base 30B model on these tasks at roughly half the disk footprint (8.37 GiB).
- Base
- A small QLoRA run on synthetic data was enough:
- We trained on 1,722 synthetic traces across 16 task families (1,712 scripted traces validated against a throwaway Coral server, plus 10 traces from
qwen3-coder:30b), covering 14.6% of an epoch (62 steps, 248 rows) before merging and quantizing toQ4_K_M. - Zero real user transcripts or developer workspaces were touched: every trace was generated and verified in an isolated sandbox under an invented account (
sandbox-dev).
- We trained on 1,722 synthetic traces across 16 task families (1,712 scripted traces validated against a throwaway Coral server, plus 10 traces from
- Honest limits—where a 14.6%-epoch scripted fine-tune breaks:
- On 10 tasks unlike the training templates (untrained subcommands like
task show,task reassign,complete --outcome failed,post --file,read --id, plus plain shell tasks), the fine-tuned 14B model scored 40% clean (mean1.10 / 2.00, up from0%on base 14B). - It generalized cleanly to several untrained commands and even recovered after guessing
task infoortask read, but when an unfamiliar prompt resembled one of its 16 trained patterns, template habits took over—wrapping$(cat notes.txt)inside a single-quoted heredoc (<<'EOF') or runningcoral-agent artifact uploadbefore creating the file.
- On 10 tasks unlike the training templates (untrained subcommands like
How We Scored Coral Tool Use (Not Chat Text)
A coding agent inside Coral does not get credit for describing a command in Markdown. It has to call pi's bash tool, pass valid CLI flags to coral-board or coral-agent, change the actual server state on a live Coral instance, and obey team guardrails.
The 10 held-out task families (t01–t10)
Each benchmark run launched an isolated Coral server with a seeded board state and gave pi (0.73.1) + Ollama (0.40.18, num_ctx 32768, temperature 0, seed 572) a one-sentence instruction:
| Task | Family | What the agent must do |
|---|---|---|
t01 | read_reply | Read unread board messages and post a reply |
t02 | backticks | Post a message containing backticks (requires a quoted heredoc or escaped backticks) |
t03 | task_add | Create and assign a task as an orchestrator (coral-board task add) |
t04 | claim | Claim an assigned task (coral-board task claim) |
t05 | complete | Mark an active task complete (coral-board task complete) |
t06 | submit_review | Submit a task for review (coral-board task submit-review) |
t07 | search | Search the board/tasks (coral-board search) and post what it found |
t08 | artifact | Upload a file (coral-agent artifact upload) and post the returned coral://artifacts/... link |
t09 | docs | Read Coral's built-in agent docs (coral-agent docs) and post the answer |
t10 | task_post | Post a reply directly on a task thread (coral-board post --task) |
The guard shell and 0 / 1 / 2 state checker
Instead of grading model prose, we pointed pi's shellPath at a guard executable that logged every command, enforced Coral's command rules, and scored the resulting server state:
- Forbidden actions (immediate score
0and run halted):- Running
coral-board join(Coral already subscribes launched agents automatically) - Posting to
@all - Touching a real
.coraldirectory or default ports - Running process-killing sweeps (
pkill,killall,taskkill /im) - Putting raw unescaped backticks inside a double-quoted
coral-board post "..."argument (which the shell would evaluate as command substitution) - Destructive deletes,
git push, orcurlto non-loopback hosts
- Running
- State-based scoring (
0,1, or2):0: Wrong board/task state, no structured tool call executed, or a forbidden command.1: The target state was reached, but a Coral command exited non-zero along the way, a required command was skipped, or extra posts/tasks were created.2(Clean): The exact board, task, or artifact state was produced with clean commands and zero errors.
We self-tested the checker against 22 hand-written cases (22 of 22 scored as expected: every right answer scored 2, every wrong answer scored 0, and two noisy answers scored 1).
Why the Base Models Struggled (0% on 14B, ~35% on 30B)
Before training anything, we ran 30 held-out evaluations (10 tasks × 3 repetitions) on both base models:
| Base Model | Runs | Mean Score (0–2) | Clean Pass (2) | Partial (1) | Fail (0) | Forbidden Rate | Tool Calls / Task | Mean Time / Task |
|---|---|---|---|---|---|---|---|---|
qwen2.5-coder:14b (base) | 30 | 0.00 | 0% | 0% | 100% | 0% | 0.0 | 9.0 s |
qwen3-coder:30b (base) | 30 | 0.73 | 33% (37% on the second base run) | 7% | 60% | 0% | 4.8 | 47.0 s |
Two distinct failure modes showed up:
qwen2.5-coder:14bnever emitted a structured tool call: In all 30 runs, it wrote fencedbashblocks in plain text (often with the rightcoral-boardcommand!) and stopped withfinish_reason: stop. Because no tool call was emitted,pinever ran a command.qwen3-coder:30bconfused CLI binaries with tool names: In 23 of 30 runs, the 30B model emitted structured tool calls, but instead of calling thebashtool withcommand: "coral-board ...", it invented tool names matching the CLI subcommands:coral-board read(12 times)coral-board task list(11 times)coral-board post(11 times)coral-agent skills list(3 times)
When pi replied "tool not found", the 30B model either gave up ("I don't have access to coral-board"), wandered through the repository with git and find, or looped on empty coral-agent tool calls until hitting the 300-second timeout. It succeeded reliably on plain posting (t02 scored 2, 2, 2), but scored 0 across task add, task claim, task submit-review, search, and docs.
The Fix: Synthetic Traces, QLoRA, and GGUF Export to Ollama
To teach qwen2.5-coder:14b how pi and Coral actually work—that every CLI command runs through bash, which flags each subcommand expects, and when to use a quoted heredoc—we built a strictly synthetic dataset:
- 1,722 synthetic training rows across 16 task families:
- Zero real user data: Every trace was generated against an isolated sandbox server running under an invented user (
USERNAME=sandbox-dev,COMPUTERNAME=SANDBOX-PC), with environment checks confirming no real home paths, account names, or hostnames existed in the environment or traces. - Split before generation: Held-out tasks (
t01–t10) used different wording and different values from the training templates, and we verified that only trace runs scoring a clean2entered the training set. - Composition: 1,712 rows came from scripted trace templates across the 16 families, plus 10 verified traces from
qwen3-coder:30b.
- Zero real user data: Every trace was generated against an isolated sandbox server running under an invented user (
- Training & GGUF export:
- We trained a QLoRA adapter on
Qwen2.5-Coder-14B-Instructfor 62 steps (248 rows, 14.6% of an epoch). - We merged the adapter into the
bf16base weights on CPU (77 seconds; layer-0q_projLoRA delta norm0.3755), converted the merged model to anf16GGUF (29.5 GB) withllama.cpp'sconvert_hf_to_gguf.py, and quantized it toQ4_K_M(8.37 GiB, 4.87 bits/weight) in 81 seconds withllama-quantize. - Finally, we registered the quantized GGUF in Ollama (
ollama create) using the exact same Modelfile tool template and parameters (temperature 0,seed 572,num_ctx 32768) as the base 14B evaluation—changing only theFROMline.
- We trained a QLoRA adapter on
Held-Out Benchmark Results: 0% → 90% Clean
We ran the exact same 30 held-out evaluations (t01–t10 × 3 repetitions) with pi's full agent prompt against the exported Q4_K_M model:
| Model | Runs | Mean Score (0–2) | Clean % (2) | Forbidden % | Runs with a Parsed Tool Call | Mean Time / Task | Prompt Tokens / Task | Output Tokens / Task |
|---|---|---|---|---|---|---|---|---|
| 14B base (same template) | 30 | 0.00 | 0% | 0% | 0 of 30 | 9.0 s | 6,556 | 47 |
| 30B base (earlier runs) | 30 | 0.73 | 33% / 37% | 0% | — | 47.0 s | 39,702 | 399 |
14B fine-tuned (Q4_K_M) | 30 | 1.90 | 90% | 0% | 30 of 30 | 7.9 s | 15,228 | 67 |
qwen2.5-coder:14b exported as Q4_K_M.Per-task breakdown (t01–t10)
| Task | Family | 14B Base | 14B Fine-Tuned (Q4_K_M) |
|---|---|---|---|
t01 read + post | read_reply | 0 / 3 | 3 / 3 |
t02 post with backticks | backticks | 0 / 3 | 3 / 3 |
t03 task add (orchestrator) | task_add | 0 / 3 | 3 / 3 |
t04 task claim | claim | 0 / 3 | 3 / 3 |
t05 task complete | complete | 0 / 3 | 3 / 3 |
t06 task submit-review | submit_review | 0 / 3 | 0 / 3 (scored 1, 1, 1) |
t07 search | search | 0 / 3 | 3 / 3 |
t08 artifact upload | artifact | 0 / 3 | 3 / 3 |
t09 agent docs | docs | 0 / 3 | 3 / 3 |
t10 post on a task | task_post | 0 / 3 | 3 / 3 |
Why did t06 (task submit-review) score 1 instead of 2 in all three runs?
- Coral's
coral-board task submit-reviewrequires either a test-result line in--messageor an explicit--no-tests "<why>"flag. - Because none of our
submit_reviewtraining traces included that refusal, the fine-tuned model's firstsubmit-reviewcommand failed with the CLI's refusal message. - On the very next turn, the model read the error and passed
--no-teststo complete the submission (reaching the right board state, which earns1), but it pasted the refusal error message itself as the--no-testsreason. Because the first command exited non-zero, the checker scored each run1instead of2.
Did it just memorize training strings, or lose general coding skill?
We ran two checks to be sure the fine-tune hadn't simply memorized training commands or degraded general coding:
- Zero verbatim copying across all 60 evaluation runs:
- We compared every command the fine-tuned model ran (across 60 total runs) against all 1,158 distinct commands in the 1,722 training rows: zero matches.
- We compared every quoted string and number in the model's commands against the training values (excluding values from the held-out prompt or command output): zero matches. In every clean run, the model plugged in the held-out task's own code words, paths, titles, and IDs.
- General coding prompts stayed intact:
- We tested both the base 14B and fine-tuned 14B models on 5 plain coding prompts without tools (Fibonacci in Python, in-place slice reversal in Go, explaining a SQL
LEFT JOIN, a bash line-count one-liner, and spotting the bug indef add(a, b): return a + c). - The fine-tuned model answered all 5 accurately with the same idioms, no stray tool calls, and nearly identical response lengths (
40–324tokens vs.40–335tokens on base; theLEFT JOINanswer was word-for-word identical).
- We tested both the base 14B and fine-tuned 14B models on 5 plain coding prompts without tools (Fibonacci in Python, in-place slice reversal in Go, explaining a SQL
The Memorization Check: 10 Tasks Unlike the Training Templates (40% Clean)
Held-out tasks t01–t10 use new wording and values, but they still map to the 16 command families in the training set. What happens when the fine-tuned 14B model faces Coral subcommands, flags, and shell tasks that never appeared in any training family?
We built a second 10-task suite (u01–u10 × 3 repetitions = 30 runs) using untrained subcommands (task show, task reassign, complete --outcome failed, post --file, read --id) alongside plain git and file tasks:
| Model | Runs | Mean Score (0–2) | Clean % (2) | Forbidden % | Runs with a Parsed Tool Call | Mean Time / Task |
|---|---|---|---|---|---|---|
| 14B base | 30 | 0.00 | 0% | 0% | 0 of 30 | 6.5 s |
14B fine-tuned (Q4_K_M) | 30 | 1.10 | 40% | 0% | 30 of 30 | 8.4 s |
Looking task by task shows both what the fine-tune learned and where template habits bite:
| Untrained Task | Fine-Tuned Score | What Happened |
|---|---|---|
u01 find who holds task #3 | 0 / 3 (scores: 1, 1, 1) | Guessed coral-board task info (no such subcommand), read the error, recovered with coral-board task list, and posted the right owner. Scored 1 because the first command failed. |
u02 report a finished task's result | 0 / 3 (scores: 1, 1, 1) | Guessed coral-board task read, recovered with coral-board task show, and posted the right value (0919). |
u03 find a deadline in a task body | 0 / 3 (scores: 1, 1, 1) | Guessed coral-board task read, recovered with coral-board task show, and posted the right deadline (14 March, noon). |
u04 reassign a task (task reassign) | 3 / 3 (clean) | Used the untrained task reassign subcommand cleanly on the first try. |
u05 fail a task (complete --outcome failed) | 3 / 3 (clean) | Passed the untrained --outcome failed flag cleanly. |
u06 post notes.txt unchanged | 0 / 3 (scores: 0, 0, 0) | Template habit: wrapped $(cat notes.txt) inside the trained single-quoted heredoc (<<'EOF'), posting the literal string $(cat notes.txt) instead of the file contents. |
u07 report the build in message #6 | 0 / 3 (scores: 0, 0, 0) | Ran coral-board read (which showed no unread messages); instead of running coral-board read --id 6, it hallucinated "the build is 6.2". |
u08 git commit + post short hash | 3 / 3 (clean) | Committed cleanly and posted the real short SHA. |
u09 write CHANGES.md and report | 0 / 3 (scores: 0, 0, 0) | Template habit: saw a file-reporting prompt and jumped straight to coral-agent artifact upload CHANGES.md (the trained artifact pattern) without creating CHANGES.md first, then posted a made-up coral://artifacts/1 link. |
u10 count lines in data.csv | 3 / 3 (clean) | Counted and reported the line count cleanly via bash. |
Look closely at the three groups in that table:
- Four untrained tasks (
u04,u05,u08,u10) passed 100% clean (3/3): Once QLoRA taught the 14B model how to emit structuredbashtool calls inpi, its pre-existing coding and CLI knowledge unlocked commands (git commit,wc -l,task reassign,--outcome failed) that were never in the fine-tune. - Three tasks (
u01,u02,u03) reached the right answer on their own (score 1): When the model guessed a plausible subcommand (task infoortask read) and got a CLI usage error, it read the output, rantask listortask show, and posted the exact answer. - Three tasks (
u06,u07,u09) failed with template habits or hallucination (score 0): Because 99% of our training set (1,712 of 1,722 rows) came from 16 scripted templates, the model over-applied two strong habits—always using<<'EOF'for multi-line posts (which prevented$(cat notes.txt)from expanding) and assuming a capital-letter filename in a prompt should be uploaded withcoral-agent artifact upload.
Honest Limits of This Trial
If you are evaluating this approach for your own local agents, keep five constraints in mind:
- 99% scripted training data: 1,712 of the 1,722 rows came from 16 scripted task templates and only 10 came from
qwen3-coder:30b. That narrow distribution is whyu06andu09showed template habits. - Only 14.6% of an epoch: The held-out jump from
0%to90%came from just 62 training steps (248 rows). We did not sweep longer training schedules or mix in general tool-use traces to soften template bias. - Fixed seed and temperature 0: All benchmark runs used
temperature 0andseed 572. For the two 14B models (base and fine-tuned), the 3 repetitions per task scored the same in all 3 reps (whereas the base 30B model varied across repetitions on several tasks even at temperature 0). For the 14B comparison, treat the result as about 20 distinct tasks (10 held-out + 10 unlike-the-templates), not 60 independent samples. - Single quantization tested: We benchmarked the exported
Q4_K_MGGUF (8.37 GiB) in Ollama; we did not benchmark the unquantizedbf16merged weights. - Data coverage matters as much as model size: The lone held-out miss (
t06,task submit-review) happened because the training generator never demonstrated--no-tests "<why>".
What This Means for Running Coral Agents on Local Models
Our first local-model trial showed that an off-the-shelf 14B model (qwen2.5-coder:14b) was unusable as a pi agent in Ollama because it never emitted a structured tool call, whereas the 30B MoE model (qwen3-coder:30b) emitted tool calls but still missed ~65% of multi-step Coral CLI tasks in the base benchmark.
This follow-up changes the picture:
- Tool-call formatting—not raw parameter count—was the 14B bottleneck: A lightweight QLoRA fine-tune (62 steps on synthetic
bashtool traces) turnedqwen2.5-coder:14bfrom 0% to 90% clean on held-out Coral tool workflows, outperforming the base 30B model (~35%) while exporting to an 8.37 GiBQ4_K_MGGUF that ran in Ollama at ~7.9 seconds per task. - CLI error messages do real work for smaller models: When the fine-tuned 14B model guessed
task infoortask readon unfamiliar tasks (u01–u03), Coral's CLI usage output was enough for a 14B model to self-correct on the next turn and post the right answer. - To go from 40% to 80%+ on unfamiliar tasks, broaden the synthetic traces: Replacing rigid scripted templates with more varied multi-turn traces—including error-recovery turns (
--no-tests,read --id, creating a file before uploading it, and choosing betweenpost --fileand<<'EOF')—is a data problem you can solve locally with a sandbox server and a state checker, without ever touching real user transcripts.
Keep reading
- Run a local Ollama model as a Coral agent with PiThe earlier trial: two local coding models run as Coral agents through Pi and Ollama on a 16 GB GPU, and why one could not use tools.
- Mixing Agent Types in CoralWhy one team can run Claude, Codex, Antigravity, OpenCode, Hermes and Pi side by side, how to set it up, and how reviews and permissions work across agents.