Skip to content

ToolCallJudge

ToolCallJudge() reads normalized tool calls from the harness run. Use it when the sequence of tools is part of the behavior you want to preserve.

evals/capital.eval.ts
import { ToolCallJudge } from "vitest-evals";
describeEval("capital questions", {
harness: qaHarness,
judges: [
ToolCallJudge({
ordered: true,
expectedTools: ["lookupCapital"],
}),
],
});

Use matcher options when a case-specific tool argument is the important assertion.

evals/capital.eval.ts
const result = await run("What is the capital of France?");
await expect(result).toSatisfyJudge(ToolCallJudge({ ordered: true }), {
expectedTools: [
{
name: "lookupCapital",
arguments: {
country: "France",
},
},
],
});

Put suite-wide expected tool names on the judge instance.

evals/capital.eval.ts
describeEval("capital questions", {
harness: qaHarness,
judges: [ToolCallJudge({ expectedTools: ["lookupCapital"] })],
});

The judge fails when a required tool is missing, an unexpected order appears in ordered mode, or configured arguments do not match the captured call. Use ordered checks only when the call order matters; leave ordering loose when multiple tool sequences are equivalent for the behavior under test.