← Back to Blog

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

  1. Held-out Coral tool tasks went from 0% to 90% clean:
    • Base qwen2.5-coder:14b: 0% clean (mean score 0.00 / 2.00), 0 of 30 runs with a parsed tool call. Every turn ended with finish_reason: stop and plain text.
    • Base qwen3-coder:30b: ~35% clean (33% / 37% across base runs, mean score 0.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 calling bash.
    • Fine-tuned qwen2.5-coder:14b (Q4_K_M in Ollama): 90% clean (mean score 1.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).
  2. 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 to Q4_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).
  3. 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 (mean 1.10 / 2.00, up from 0% on base 14B).
    • It generalized cleanly to several untrained commands and even recovered after guessing task info or task 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 running coral-agent artifact upload before creating the file.

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:

TaskFamilyWhat the agent must do
t01read_replyRead unread board messages and post a reply
t02backticksPost a message containing backticks (requires a quoted heredoc or escaped backticks)
t03task_addCreate and assign a task as an orchestrator (coral-board task add)
t04claimClaim an assigned task (coral-board task claim)
t05completeMark an active task complete (coral-board task complete)
t06submit_reviewSubmit a task for review (coral-board task submit-review)
t07searchSearch the board/tasks (coral-board search) and post what it found
t08artifactUpload a file (coral-agent artifact upload) and post the returned coral://artifacts/... link
t09docsRead Coral's built-in agent docs (coral-agent docs) and post the answer
t10task_postPost 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:

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 ModelRunsMean Score (0–2)Clean Pass (2)Partial (1)Fail (0)Forbidden RateTool Calls / TaskMean Time / Task
qwen2.5-coder:14b (base)300.000%0%100%0%0.09.0 s
qwen3-coder:30b (base)300.7333% (37% on the second base run)7%60%0%4.847.0 s

Two distinct failure modes showed up:

  1. qwen2.5-coder:14b never emitted a structured tool call: In all 30 runs, it wrote fenced bash blocks in plain text (often with the right coral-board command!) and stopped with finish_reason: stop. Because no tool call was emitted, pi never ran a command.
  2. qwen3-coder:30b confused CLI binaries with tool names: In 23 of 30 runs, the 30B model emitted structured tool calls, but instead of calling the bash tool with command: "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:

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:

ModelRunsMean Score (0–2)Clean % (2)Forbidden %Runs with a Parsed Tool CallMean Time / TaskPrompt Tokens / TaskOutput Tokens / Task
14B base (same template)300.000%0%0 of 309.0 s6,55647
30B base (earlier runs)300.7333% / 37%0%—47.0 s39,702399
14B fine-tuned (Q4_K_M)301.9090%0%30 of 307.9 s15,22867
Clean-pass rate on the 30 held-out runs
10 held-out tasks × 3 repetitions. Clean means score 2: the exact board, task or artifact state, with no command errors.
Clean-pass rate on 30 held-out runs0%50%100%Base 14B0% (0 of 30)Base 30B~35% (33%, 37%)Fine-tuned 14B90% (27 of 30)
Base 30B is shown at about 35%, the midpoint of its two base runs (33% and 37%). The fine-tuned model is qwen2.5-coder:14b exported as Q4_K_M.

Per-task breakdown (t01–t10)

TaskFamily14B Base14B Fine-Tuned (Q4_K_M)
t01 read + postread_reply0 / 33 / 3
t02 post with backticksbackticks0 / 33 / 3
t03 task add (orchestrator)task_add0 / 33 / 3
t04 task claimclaim0 / 33 / 3
t05 task completecomplete0 / 33 / 3
t06 task submit-reviewsubmit_review0 / 30 / 3 (scored 1, 1, 1)
t07 searchsearch0 / 33 / 3
t08 artifact uploadartifact0 / 33 / 3
t09 agent docsdocs0 / 33 / 3
t10 post on a tasktask_post0 / 33 / 3

Why did t06 (task submit-review) score 1 instead of 2 in all three runs?

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:

  1. 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.
  2. 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 in def 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–324 tokens vs. 40–335 tokens on base; the LEFT JOIN answer was word-for-word identical).

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:

ModelRunsMean Score (0–2)Clean % (2)Forbidden %Runs with a Parsed Tool CallMean Time / Task
14B base300.000%0%0 of 306.5 s
14B fine-tuned (Q4_K_M)301.1040%0%30 of 308.4 s
Held-out tasks vs. tasks unlike the training templates
Each suite is 10 tasks × 3 repetitions (30 runs). Treat the 14B comparison as about 20 distinct tasks, not 60 independent samples.
Clean-pass rate, held-out vs unlike-the-templates tasks0%50%100%Held-out tasks (t01–t10)Base 14B0%Fine-tuned 14B90%Unlike the templates (u01–u10)Base 14B0%Fine-tuned 14B40%
Second suite: 10 tasks using subcommands, flags and shell tasks that were not in any training family. The fine-tuned model scored 40% clean there.

Looking task by task shows both what the fine-tune learned and where template habits bite:

Untrained TaskFine-Tuned ScoreWhat Happened
u01 find who holds task #30 / 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 result0 / 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 body0 / 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 unchanged0 / 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 #60 / 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 hash3 / 3 (clean)Committed cleanly and posted the real short SHA.
u09 write CHANGES.md and report0 / 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.csv3 / 3 (clean)Counted and reported the line count cleanly via bash.

Look closely at the three groups in that table:

  1. Four untrained tasks (u04, u05, u08, u10) passed 100% clean (3/3): Once QLoRA taught the 14B model how to emit structured bash tool calls in pi, its pre-existing coding and CLI knowledge unlocked commands (git commit, wc -l, task reassign, --outcome failed) that were never in the fine-tune.
  2. Three tasks (u01, u02, u03) reached the right answer on their own (score 1): When the model guessed a plausible subcommand (task info or task read) and got a CLI usage error, it read the output, ran task list or task show, and posted the exact answer.
  3. 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 with coral-agent artifact upload.

Honest Limits of This Trial

If you are evaluating this approach for your own local agents, keep five constraints in mind:

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:

  1. Tool-call formatting—not raw parameter count—was the 14B bottleneck: A lightweight QLoRA fine-tune (62 steps on synthetic bash tool traces) turned qwen2.5-coder:14b from 0% to 90% clean on held-out Coral tool workflows, outperforming the base 30B model (~35%) while exporting to an 8.37 GiB Q4_K_M GGUF that ran in Ollama at ~7.9 seconds per task.
  2. CLI error messages do real work for smaller models: When the fine-tuned 14B model guessed task info or task read on 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.
  3. 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 between post --file and <<'EOF')—is a data problem you can solve locally with a sandbox server and a state checker, without ever touching real user transcripts.

Try Coral

Open source. Runs on your own computer.

Download Coral

Keep reading