Own Weights

Fine-tuning for function and tool calling in agents

Fine-tuning for function calling: how a small trained model can run one agent step with exact tool calls, tested on your own data before you switch.

Updated

Fine-tuning for function calling means training an open-weight model on examples of one step’s correct tool calls: the right function name, and arguments that match the input every time. A small trained model can do this well when the step has a fixed set of tools and the input contains the values the arguments need.

Can a small model do tool calling?

Yes, for a narrow step. A small model fine-tuned on your own tool calls can pick the correct tool from a short list and fill in its fields in the format your code expects. It does not need a long system prompt that lists every tool and every rule.

It is a poor fit for open-ended planning. If the agent must decide across many tools, invent a new sequence of calls, or handle requests it has never seen, keep the frontier model for that work. Tool arguments are JSON, so the output format matters as much as the choice of tool. Making LLM JSON output reliable covers the format side.

Which agent step is worth replacing?

Look for the step that runs most often and changes least. Good candidates are classifying an incoming ticket and calling one of a few routing tools, looking up a customer record from a request, or calling a formatting tool on every output. These steps run on every request, and the correct answer is usually already in the input.

Here is a hypothetical example with round numbers. An agent runs a routing step 1 million times a month, and each call sends 1,000 input tokens. That is 1 billion input tokens a month. At the Claude Opus list price of $4 per million input tokens, the input alone costs $4,000 a month before any output. At the Claude Haiku list price of $0.10 per million input tokens (prompts up to 100K tokens), the same input costs $100. Check current pricing pages for other vendors.

Price is only half the decision. A cheaper model that picks the wrong tool costs more in the end, because the agent retries, asks again, or fails. Count correct calls, not tokens.

How do you replace the frontier model in an agent pipeline?

Use the same steps you would use for any task you move off a frontier API, with the tool call as the score.

  1. Audit. Map AI spend by task, using your code and invoices. The audit is free.
  2. Evaluate. Pull real inputs for the step from your logs, along with the tool call the current model made. Score the current model first. A call counts as correct only if the tool name and every argument match.
  3. Train. Fine-tune an open-weight model on the training split. Keep the test cases out of training, so the score means something.
  4. Gate. The trained model must beat the current model on your test before it goes live. If it does not, do not deploy it.
  5. Serve. Run it in your own cloud account or on-prem, tuned for throughput. You own the weights.

Keep a fallback path for inputs outside the trained tool set. A routing step can send unclear cases to the frontier model, and you can track how often that happens. If the fallback rate climbs, that is a sign the step has changed and needs new training data.

What did our test show?

Our public test was not a tool-calling test. It was contract extraction: 510 commercial contracts, with answers marked by lawyers, scored by the share of exactly-right quotes. Our Accuracy model scored 0.717, our Standard model scored 0.650, Claude Opus scored 0.635, and Claude Haiku scored 0.584. Our lead over Opus was +0.082 and over Haiku was +0.133, both larger than the margin of error.

Claude took that exam with one prompt, no examples and no task training. Our models were fine-tuned for this exam. That shows what training for one task does. It does not show how a model handles your tools, and it does not mean our model beats Claude at everything. Fine-tuned models can beat frontier models on a narrow task with good data. They do not always do.

On the same exam, our Accuracy tier cost $4.50 per 1,000 documents, our Standard tier cost $3.54, Claude Haiku cost $4.95, and Claude Opus cost $154.49 at list price for the tokens it used. One request at a time, Accuracy wrote about 90 output tokens per second and Standard about 174, with Standard’s first token in about 0.3 seconds. Full results are on the benchmark page. A tool call is much shorter than a contract, so treat these numbers as a guide for your step, not a forecast.

When is fine-tuning the wrong choice?

Skip it when the agent’s job changes every week, when you do not yet have enough good examples of the step, or when a single frontier call costs less than the time to build the test. Skip it when the step needs broad reasoning that the small model has not seen. Small models for agentic workflows are a good fit for the steps that repeat. They are a poor fit for the agent’s judgment about what to do next. Our guide on small models covers where the trade-off tips.

If an agent step is a large part of your bill, start with the free AI cost audit. It reads your code on your machine, makes no network calls while it reads, and uploads nothing. If it finds a repeated step with a fixed set of tools, book a call with Own Weights. We will test whether a trained model can run that step on your data before anyone commits to a deployment.

Questions

Can a small model do tool calling?

Yes, when the step has a fixed set of tools and the input already holds the values the arguments need. Accuracy falls when the model must invent a plan or call a tool it was never trained on. Score exact tool calls on a test built from your own logs before you rely on it.

Is a fine-tuned model for AI agents worth it?

It is worth it for the repeated steps inside an agent, not for the whole agent. Keep the frontier model for steps that need open-ended planning. A trained model only saves money if it passes your test at the accuracy you need.

Why is my agent step too expensive on GPT?

A large model often handles a short, repeated decision, and every call resends the same tool list and instructions. Check OpenAI's current pricing page for the rates that apply to you. Then compare cost per correct tool call, not cost per token.

What are small models for agentic workflows good at?

Narrow decisions with a fixed output: picking a tool, filling its fields, and returning them in the format your code parses. They are weaker at long plans and at tools that change every week. Test the exact outputs your code depends on before you move traffic.