Most of the cost of an agent in production lands on a small set of steps that repeat thousands of times a day: route this ticket, pull these six fields out of an invoice, decide whether this message needs a person. Each of those calls is a chance to stop paying a frontier model to do a narrow job it was never specialised for. Distillation is the way to move those steps onto a model you own.
This post covers the mechanics: what a trace is, how it becomes a training example, which steps are worth distilling, and how the router and the fallback control the cutover.
What distillation means here
The term is old. In Distilling the Knowledge in a Neural Network (Hinton, Vinyals and Dean, 2015), a large “teacher” model is compressed into a smaller “student” by training the student to match the teacher’s outputs, not just the ground-truth labels. The key idea is that the teacher’s soft output carries more signal than a hard label: a teacher that says “8 with probability 0.7, 3 with 0.2” teaches the student something about how 8s and 3s are shaped alike.
When people talk about distilling an LLM agent, the mechanics are close but the thing being transferred has changed. The teacher here is a frontier model running your agent. The student is an open model you fine-tune. What you transfer is the teacher’s concrete behaviour: given this exact context, here is what it answered and which tools it called with which arguments. The unit of transfer is a trace, and the target is behaviour.
That distinction matters because it tells you what the training data has to contain. A final answer alone is not enough. If the agent called a tool first, reasoned, then answered, you want all of that in the example, or the student never learns the middle step.
A trace, and which traces you can use
In turion’s tracing, one trace is one model call the agent made. A run of the agent is usually several traces, because an agent that plans, calls a tool and then answers has made several model calls along the way. A usable trace for distillation is one a provider or the model garden answered successfully and in full, and not a duplicate of another trace. Calls that were cut off, errored, or were served by a previous fine-tune of your own are excluded, because you don’t want to train the student on the student.
That last exclusion is subtle and worth pausing on. Once a distilled model is serving some of your traffic, its own answers start appearing in the trace store. If you let those back into the next training run, the student begins to learn from itself, and small errors compound. Distillation always reads back past the fine-tune, to the frontier model’s traces only.
Each trace is turned into a chat example in the OpenAI messages shape: the request’s messages and tools, followed by the assistant turn the model actually produced, tool calls included. Duplicates are dropped. So a trace of a triage step that called get_customer with {"id": "4417"} and then answered becomes one training row with the full conversation, exactly as the base model’s chat template will see it at serving time.
One of the quieter failure modes in fine-tuning is a mismatch between how an example looks in training and how the request looks in production. Building the example from the trace, tool definitions and all, avoids most of it.
From traces to a training run
turion agent distil does the conversion in one command, but the steps are worth seeing as separate because each is where a project can go wrong.
- It reads the agent’s newest 20,000 usable traces (never more, never a previous fine-tune’s output).
- Each becomes a chat example as above; duplicates are dropped.
- The examples are split 90/10 into two datasets: the training set and a held-out eval set.
- An ordinary LoRA fine-tuning job runs on the agent’s configured distil base, with the held-out tenth scored as the eval.
The command refuses to run below a minimum of 1,000 usable traces by default, and you can lower that only to try the flow on a test agent. That floor exists for a reason: distillation is supervised learning on a small open model, and a few hundred traces is enough to memorise the teacher’s phrasing, not enough to generalise.
The eval is the part that makes the whole thing defensible. The job scores both the untouched base model and the distilled model on the same held-out traces and reports both pass rates, so you can separate “the base was already fine” from “the distillation taught it something.” The gap between the two is what your traces contributed.
What the student learns
It’s tempting to think of distillation as the student learning to imitate the frontier model in general. It doesn’t. The student is a small open model trained on one job’s traces, so it learns that job: your option labels, your field names, your tool arguments, your edge cases. The frontier model contributes breadth; you throw most of that away on purpose, because breadth is what you were paying for and not using.
This is the same bet behind task-specific language models generally. Small language models covers the evidence for when a fine-tuned open model beats a frontier model on a narrow task and when it doesn’t. Distillation is how you get the training data when you don’t have human-labelled examples but you do have a frontier model already doing the job well enough to trace.
The fine-tuning method underneath is LoRA by default: frozen base weights plus a small adapter, which keeps the artifact tiny and cheap to retrain. LoRA and QLoRA explains the mechanics. For distillation the method matters less than the data, but LoRA matters operationally: a small adapter means you can retrain on fresh traces on a schedule without it being a project.
Which steps are worth distilling
The short answer: steps that repeat, have a fixed shape, and can be scored automatically.
| Worth distilling | Not worth distilling |
|---|---|
| Routing and triage: a label from a list | Open-ended planning across novel situations |
| Extraction: fields pulled from a document | Tasks with little repetition, where GPU time costs more than a per-call API price |
| Tool selection and arguments for common cases | Reasoning the frontier model still does better than you can evaluate |
| Formatting and short answers in a set format | Work where the schema or domain shifts weekly and nobody retrains |
There’s a second filter that matters more than the task type: can you tell, in code, whether the distilled model got it right? If the answer has a fixed shape, you can. That’s what the eval set and the fallback both depend on. A step you can’t score is a step you can’t safely move traffic onto, whatever the task is.
Keep the frontier model’s failures in the eval set. If the frontier model is wrong on 8% of its traces, and you distil all of them, you train the student to reproduce that 8%. A distillation run that keeps the failures in the eval set — even if it filters them from training — at least shows you the ceiling before you find out in production.
The router and the fallback
Once the distilled model is deployed, you route the agent to it at a share you choose. Each model call the agent makes goes to the distilled model with that probability and to the frontier model otherwise. A call the distilled model answers with an error is retried on the frontier model, and the trace records the fallback, so you can see exactly how often the student is leaning on the teacher.
The point of the router is that the eval, not a human at cutover, decides the share. You start at a low share, watch the held-out score and the fallback rate, and raise the share as the distilled model proves itself. turion agent eval --remote scores whatever the route is actually serving, route included, so the number you read is the system in production.
So “the distilled model matches the frontier model” means something specific: it matches on your eval set, at the share you’ve routed, with the fallback catching its errors.
Doing it on turion
If you have an agent in production whose calls are being traced, the loop is four commands. First, check how close you are to a usable training set:
turion agent get support-triage
It prints the usable-trace count against the 1,000 default threshold and the base it would distil onto. Then distil:
turion agent distil support-triage --follow
This builds the two datasets (about 90% train, 10% held out) and starts an ordinary training job on the agent’s distil base. When it finishes, deploy and route:
turion deploy acme/support-triage-distil-1a2b3c
turion agent route support-triage \
--model acme/support-triage-distil-1a2b3c --share 20
Each call now goes to the distilled model with 20% probability and to the frontier model otherwise; a failed call is retried on the frontier model. Raise the share as the eval holds:
turion agent eval --remote
Training is billed per GPU-second at $1.80 per GPU-hour, and the deployed model is billed per GPU-second while its replicas are up, at $0.0005 per GPU-second; it scales to zero when idle, so the router’s low-traffic share costs nothing between calls beyond the keep-alive. The evaluate, distil and route guide has the full reference, and the distillation page covers the managed version, where we build the eval set from your traces and run the whole loop with you.
The frontier model still does the hard, novel work. Distillation stops paying it to do the same thousand judgments a day.