To test LLM tool calls, list the tools the model can use, write down the calls you expect for each input, and fail the build when the model's calls drift away from them. Drift-CI's tool-call evaluator does this on every pull request, with no judge model, and multi-step cases answer each call from scripted results so a whole agent flow runs without touching your real systems.
Why tool calling breaks
Agents fail quietly. The reply still reads well, but behind it:
- the model picks the wrong tool, such as
cancel_orderwhen the user asked where an order is; - it gets an argument wrong, often an ID copied out of a long message;
- it calls a tool when it shouldn't, on a "thanks, that's all" message;
- in a multi-step flow it skips a step, such as cancelling without first checking the order hasn't shipped.
Prompt edits, new tools in the list and model upgrades all shift this behaviour, and it usually shifts on some inputs and not others. You only see it if you test the calls, not just the text.
Test LLM tool calls with the tool-call evaluator
Define tools once for the suite, then give each case the calls you expect in expectedCalls:
evaluators: [tool-call]
tools:
- name: get_order
description: Look up an order by its ID
parameters:
type: object
properties: { order_id: { type: string } }
required: [order_id]
- name: cancel_order
description: Cancel an order that has not shipped yet
parameters:
type: object
properties: { order_id: { type: string } }
required: [order_id]
cases:
- id: order-lookup
input: "Where is order ORD-123?"
expectedCalls:
- name: get_order
arguments: { order_id: ORD-123 }
- id: thanks-no-tool
input: "Thanks, that's all I needed!"
expectedCalls: []tool-call scores each case from 0 to 1:
- Only the arguments you list are compared. Extra top-level arguments the model sends are ignored, so you can pin the one field that matters.
- Each call scores the share of its listed arguments that match. Strings are compared after trimming, objects and arrays deeply.
- Extra and missing calls lower the score. The case score is the sum of the call scores divided by the larger of the expected and actual call counts.
expectedCalls: []means "answer without a tool". It scores 1 when the model calls nothing and 0 when it calls anything.
The suite is checked when it loads: every expected call must name one of the case's tools, so a typo fails at once rather than scoring 0 forever. A case can also add its own tools, or replace a suite tool with the same name.
Multi-step agent flows with scripted results
Many agent tasks take several calls: look something up, then act on what came back. Give the case toolResults and Drift-CI answers each call from your script, then lets the model carry on until it replies without a call:
- id: cancel-if-unshipped
input: "Can you cancel order ORD-555 if it hasn't shipped yet?"
toolResults:
- name: get_order
arguments: { order_id: ORD-555 }
result: { order_id: ORD-555, status: processing }
- name: cancel_order
arguments: { order_id: ORD-555 }
result: { ok: true }
maxSteps: 4
expectedCalls:
- { name: get_order, arguments: { order_id: ORD-555 } }
- { name: cancel_order, arguments: { order_id: ORD-555 } }
- id: no-cancel-once-shipped
input: "Can you cancel order ORD-556 if it hasn't shipped yet?"
toolResults:
- name: get_order
result: { order_id: ORD-556, status: shipped }
- name: cancel_order
result: { ok: true }
expectedCalls:
- { name: get_order, arguments: { order_id: ORD-556 } }The second case is the one that catches real bugs. The order has shipped, so the right flow is one lookup and no cancellation. If the model cancels anyway, it makes two calls against one expected and the case scores 0.5.
How the loop works:
- Matching. Each call is answered by the first scripted result with the same name whose listed
argumentsmatch. An entry withoutargumentsanswers any call to that tool. - Unscripted calls. A call nothing matches gets an error result,
no result scripted for <name> with these arguments, and the model carries on, just as it would after a real tool error. maxSteps. The number of model replies a case may take, 1 to 10 (5 by default). A case that hits the limit is scored as it stands.- Scoring.
tool-callscores the calls from every step together, in any order. - Cost. Token usage, and so the cost shown in the report, is summed across steps.
Reading the result in a pull request
The stored output of a tool case is a transcript: a → line for each call and a ← line for each result, then the model's final answer.
→ get_order {"order_id":"ORD-556"}
← {"order_id":"ORD-556","status":"shipped"}
Order ORD-556 has already shipped, so I can't cancel it. You can return it once it arrives.That transcript is what goes into the baseline and the PR comment, so a reviewer sees which calls changed, not just that a score dropped. Other evaluators on the case see it too: add llm-judge with criteria about the final answer to check the reply as well as the calls, and the case score combines both.
What we saw in our own suite
Our dogfood repository runs a support-ticket suite against claude-sonnet-4-6, and we added five tool cases to it for an order-support agent with get_order, cancel_order, issue_refund and escalate_to_human. Two are single-step: a lookup by order ID, and a "thanks, that's all" message that should get no tool call. Three are multi-step with scripted results: cancel an order that's still processing, don't cancel one that has shipped, and escalate a $649 refund to a human because the agent may only refund up to $100. Sonnet 4.6 scored 1.0 on all five, and those runs became the baselines.
Then we opened a pull request that swapped the agent to the cheaper claude-haiku-4-5. All five tool cases held at 1.0: Haiku looked orders up with the right IDs, refused to cancel the shipped order and escalated the large refund. The check still failed, because two structured-output cases in the same suite dropped from 1 to 0, the same breakage described in testing LLM JSON output.
That's the useful part. A model swap isn't safe or unsafe as a whole; it's safe for some behaviours and not others. One PR comment showed which was which: tool use could move to the cheaper model, structured output couldn't without a prompt change.
Running it in CI
Run the suite on every pull request with the Drift-CI GitHub Action, then accept the baselines once each case behaves the way you want. From then on, a prompt edit or a new tool that changes which calls the model makes fails the check in review.
Run a tool suite before switching models, so you know whether tool use is one of the things that moved; testing an LLM model upgrade covers that workflow. If your tools return structured data that your code parses, testing LLM JSON output covers the schema side. The LLM regression testing guide explains baselines, thresholds and how tool checks fit next to judges and similarity scoring.
The full example is tools.yaml in the Drift-CI repository.