Evaluating Tool-Calling Agents: Trajectory Scoring, Tool Accuracy, and Argument Fidelity
Evaluating an agent only by reading its final text answer misses critical bugs: the agent might have called three unnecessary expensive tools, passed a wrong date range and guessed the rest, or triggered a mutating tool when it should have asked for confirmation. Trajectory evaluation inspects the full sequence of tool calls alongside the final outcome.
Four Dimensions of Trajectory Evaluation
| Dimension | Question Answered | Scoring Approach |
|---|---|---|
| Tool Selection Accuracy | Did the agent invoke the required tools (and avoid forbidden ones)? | Set / sequence assertion against expected tool list |
| Argument Fidelity | Were dates, IDs, filters, and units grounded in user input? | Deterministic predicate check on tool arguments |
| Efficiency | Did it finish within an acceptable step and token budget? | Step count & cost threshold assertions |
| Outcome Groundedness | Does the final answer match the actual tool outputs? | Claim check against observed tool payloads |
Deterministic Mock Sandboxes for CI
Never run CI agent evaluations against live production third-party APIs. Build a deterministic mock tool harness that returns realistic fixtures (including empty results, partial pagination, and transient errors) so you can verify how the agent behaves under both happy paths and failure modes.
export interface AgentTrajectoryAssertion {
requiredTools: string[];
forbiddenTools?: string[];
maxSteps: number;
verifyArgs?: (calls: RecordedToolCall[]) => boolean;
}
export function scoreTrajectory(
calls: RecordedToolCall[],
spec: AgentTrajectoryAssertion
): { passed: boolean; failures: string[] } {
const failures: string[] = [];
const calledNames = new Set(calls.map(c => c.name));
for (const req of spec.requiredTools) {
if (!calledNames.has(req)) failures.push(`Missing required tool: ${req}`);
}
for (const bad of spec.forbiddenTools ?? []) {
if (calledNames.has(bad)) failures.push(`Called forbidden tool: ${bad}`);
}
if (calls.length > spec.maxSteps) {
failures.push(`Exceeded maxSteps (${calls.length} > ${spec.maxSteps})`);
}
if (spec.verifyArgs && !spec.verifyArgs(calls)) {
failures.push("Tool argument predicate failed");
}
return { passed: failures.length === 0, failures };
}
Next: see how latency and turn-taking change when agents speak in real time in Voice and Multimodal AI Pipelines.