A tool call that is 95% right still fails. Supervised fine-tuning shows a model the correct call but never the plausible wrong one. Here is what preference data changes, and how to test for near-misses.
In this article (11)Expand โCollapse โ
- Your agent called the right tool and still broke
- The gap supervised fine-tuning leaves open
- What "plausible wrong" actually means
- How DPO uses that contrast
- A near-miss test you can run today
- Where the near-misses come from
- The tradeoff: preference data versus eval coverage
- What this means for your prompts and schemas
- When to reach for preference data
- Further reading
- Sources
Your agent called the right tool and still broke
Your agent picked the right function. It passed the right arguments. Then the API returned a 400, and the whole multi-step task stalled.
The bug was a single field. The model sent "limit": "10" as a string instead of 10 as a number. Or it wrapped the arguments in a parameters key the schema never declared. Or it emitted the call as text inside a Markdown code fence instead of a structured tool call.
This is the formatting failure that eats agent demos. The decision was right. The encoding was wrong. And most fine-tuning pipelines never teach the model the difference.
The gap supervised fine-tuning leaves open
Supervised fine-tuning (SFT) trains a model on demonstrations. You show it a prompt and the correct tool call, and it learns to reproduce that call. That is useful. It is also one-sided.
A recent arXiv paper on TOUMAII puts the problem plainly. SFT "optimises for producing the correct call, but never contrasts it with a plausible incorrect one." The model sees the right answer many times. It never sees the near-miss answer labeled as wrong.
So the model learns the general shape of a good call. It does not learn the boundary. When a schema is ambiguous, or a field is optional in one tool and required in another, the model guesses. Sometimes it guesses a call that is 95% correct.
Five percent wrong is still a failed call.
What "plausible wrong" actually means
A plausible wrong call is not random garbage. It is the call a competent model would produce if it half-understood the schema. It looks right at a glance.
Here is the distinction in practice, using a hypothetical weather tool:
{
"name": "get_forecast",
"arguments": { "city": "Lisbon", "days": "3" }
}The call names the right function and the right city. The days value is a string. If the schema declares days as an integer, a strict validator rejects it. A lenient one coerces it and hides the bug until a stricter endpoint appears.
A preference pair for this case holds the correct call next to that string-typed near-miss, marked as rejected. The model sees both and learns which one to prefer.
How DPO uses that contrast
Direct preference optimization (DPO) is a training method that learns from pairs of answers: one preferred, one rejected. Instead of teaching "produce this," it teaches "prefer this over that."
For tool calling, the pair is a correct call and a plausible incorrect one. The TOUMAII paper argues DPO "targets exactly this contrast" and therefore needs preference pairs rather than plain demonstrations.
The authors built a dataset of roughly 4.5 million validated preference pairs from existing tool-calling conversations. They also released a generator, TOUMAII-Gen, that takes an SFT dataset and produces preference pairs containing model-generated failure modes. They report fine-tuning a 3-billion-parameter model to parity with other tool-calling preference datasets, and they show the pipeline works on a second source dataset.
That last point matters for your own work. The generator is source-agnostic: you feed it your SFT data and it produces contrasts. You are not locked to their conversations.
A near-miss test you can run today
You do not need DPO to benefit from this idea. You need evals that check the shape of a call, not just whether it ran.
The script below takes a model's tool call as a string, parses it, and checks types against a small schema. It treats a string-typed number as a failure, which is the near-miss most validators silently coerce.
import assert from "node:assert";
const schema = {
get_forecast: { city: "string", days: "number" },
};
function checkCall(raw) {
let call;
try {
call = JSON.parse(raw);
} catch (err) {
return { ok: false, reason: `unparseable JSON: ${err.message}` };
}
const fields = schema[call?.name];
if (!fields) return { ok: false, reason: `unknown tool: ${call?.name}` };
for (const [key, type] of Object.entries(fields)) {
const value = call.arguments?.[key];
if (value === undefined) return { ok: false, reason: `missing field: ${key}` };
if (typeof value !== type) {
return { ok: false, reason: `${key} should be ${type}, got ${typeof value}` };
}
}
return { ok: true };
}
const good = '{"name":"get_forecast","arguments":{"city":"Lisbon","days":3}}';
const nearMiss = '{"name":"get_forecast","arguments":{"city":"Lisbon","days":"3"}}';
assert.equal(checkCall(good).ok, true);
assert.equal(checkCall(nearMiss).ok, false);
console.log("near-miss caught:", checkCall(nearMiss).reason);Run it with node near-miss.mjs. The second assertion is the one that protects you. If your eval suite passes the near-miss, your suite is not testing formatting.
This is the same discipline as testing what your LLM agent actually did in CI: assert on the artifact, not on the happy path.
Where the near-misses come from
You can collect them without a preference dataset. Log every tool call your agent makes in staging, then mine the failures.
The common shapes, based on the failure modes the TOUMAII generator is designed to reproduce:
- A number sent as a string, or a boolean sent as
"true". - Arguments nested under the wrong key, such as
parametersinstead ofarguments. - A tool call emitted as prose or inside a code fence instead of structured output.
- A required field omitted because it was optional in a sibling tool.
- Parallel calls issued sequentially, or the reverse, when the task needs one order.
Each of these is a candidate preference pair. The correct call is your golden output. The near-miss is the logged failure. That is the contrast, built from your own traffic.
The tradeoff: preference data versus eval coverage
Preference data is not free. Someone has to validate each pair. A wrong label teaches the model the wrong preference, and that is worse than no pair at all. The TOUMAII authors call their pairs "validated" for that reason.
Evals are cheaper per case but do not improve the model. They only tell you when it fails.
Approach โ Cost โ What it buys you ยท More SFT examples โ Low per example โ Better average call, same blind spots ยท Preference pairs โ Higher, needs validation โ Learns to reject near-misses ยท Eval cases โ Low โ Detects failures, does not fix them
The practical order: write evals first, find the near-misses that actually occur, then build preference pairs only for those. Do not generate pairs for every theoretical mistake. Your traffic tells you which ones matter.
One limit worth stating. The paper reports parity with other preference datasets, not a large jump. Preference data is not a magic fix for a model that cannot reason about which tool to call. It sharpens the boundary between a good call and a nearly-good one. If the decision itself is wrong, no amount of formatting contrast helps.
What this means for your prompts and schemas
A model trained on contrasts is better at rejecting near-misses. It is not a substitute for a clear schema. If your tool definition says days is a number, say so in the description, and validate on your side anyway.
Two habits pay off regardless of training:
First, make your validator strict. Reject string-typed numbers instead of coercing them, at least in staging. Coercion hides the exact failure a preference-trained model was taught to avoid.
Second, keep your schemas small and explicit. A tool with twelve optional fields gives the model twelve chances to produce a plausible wrong call. Splitting it into focused tools reduces the surface. The same principle shows up in setting up a Python project so your agent stops guessing: constrain the environment and the agent makes fewer wrong turns.
When to reach for preference data
If you are prompting a hosted model, you cannot run DPO yourself. Your lever is the prompt, the schema, and the eval. Use the near-miss test above and log failures.
If you are fine-tuning, preference data becomes an option. Reach for it when your evals show a pattern: the model picks the right tool but mangles the call in a consistent way. That pattern is what a preference pair fixes. If the failures are scattered and random, more SFT data or a tighter schema will do more.
The TOUMAII release is useful here because the generator is open and the pipeline is source-agnostic. You can point it at your own SFT conversations and get pairs that reflect your tools, not a generic benchmark. Whether that beats hand-written pairs depends on how much your failure modes look like theirs. The paper does not claim it does. Test it against your eval set before you trust it.
Further reading
- The script ran. That is the weakest signal you have.
- Python Persistence: When to Move from JSON to SQLite
Sources
- TOUMAII: A 4.5M-Pair Tool-Calling Preference Dataset and Its Source-Agnostic Generator โ arXiv cs.AI, 2026-11-23