Interview's MateAI Engineering
Interview's Mate

AI Engineering

LLMs, RAG, agents & evals

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
AI Engineering topics
Lesson 69/ 160
04. Evals

Tool Call Accuracy

Did the agent pick the right tool with the right arguments at the right time?

IntermediateTool Choice · Args Match3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidHands-onQuiz (3)Practice

In plain words

Tool-call accuracy checks whether the AI pressed the right button with the right details, and didn't press buttons it shouldn't.

Think of it like…

A call-centre agent using internal systems: did they open the right system, type the right customer ID and amount, and avoid pressing buttons they didn't need to? You audit the clicks, not just the conversation.

Where you’ve seen it

An order-support agent has tools search_orders, get_order, issue_refund and escalate. On 150 golden cases the team measures: correct tool selected on the first step 94%; arguments exactly correct on 81% (most misses are ambiguous dates like "last Friday" and refund amounts with the wrong currency rounding); schema-valid calls 99%; unnecessary calls on 7% of cases; correct abstention (asked a clarifying question instead of guessing an order ID) on 22 of 30 ambiguous cases (73%). After tightening the issue_refund description and adding an enum for reason, argument accuracy rises from 81% to 90% and unnecessary calls fall from 7% to 3%.

Words you’ll hear

Tool selection accuracy
Share of steps where the agent picks the expected tool.
Argument accuracy
Whether call parameters are valid and match the expected values.
Unnecessary call
A call that isn't needed to complete the task.
Abstention
Correctly not calling a tool, asking for clarification or refusing instead.

Visual diagram

Loading interactive diagram

Theory & deep dive

What to measure and how

Define the expected call (or set of acceptable calls) for each golden case. Then score: name match; schema validity (does the JSON parse and satisfy the declared types and required fields, checked with the same validator your runtime uses); argument match, comparing after normalisation (trim and lowercase strings, parse dates to ISO form, compare numbers with tolerance, treat optional fields with defaults as equal) and with partial credit per argument so you can see which parameter fails; and extra or missing calls. For free-text arguments such as a search query or message body, use a similarity or LLM judge rather than exact match.

Include negative and ambiguous cases: requests where no tool applies (a greeting, an out-of-scope question), where required information is missing (the correct behaviour is to ask), and where a dangerous action needs confirmation. Report precision and recall style numbers: how often a call was made when it shouldn't have been, and how often a needed call was skipped. Where several valid paths exist, specify *sets* of acceptable calls or write outcome checks that run the tool against a sandbox and compare the resulting state.

A scoring record

{"case": "refund-017", "tool_ok": true, "schema_ok": true, "args": {"order_id": "match", "reason": "match", "amount": "mismatch (expected 49.90, got 50)"}, "extra_calls": 0} Partial credit shows that only the amount rounding failed.

Key takeaway: Check name, schema and normalised arguments with partial credit, and include negative cases.

Improving and monitoring

Break scores down per tool and per argument: a single weak tool description (ambiguous parameter names, missing enum, undocumented format) typically explains most errors. Fixes in order of effort: clearer names and descriptions, enums and constrained types, examples in the description, fewer overlapping tools, schema-level strict mode or constrained decoding to guarantee valid JSON, and few-shot examples for tricky formats. Re-run the suite on every tool schema, prompt or model change, since upgrades can shift behaviour subtly (more eager calling, different date handling).

In production, log every call with its arguments and outcome and monitor error rates, retry loops, schema violations and calls rejected by validation or permission checks. Sample failures into the golden set. Remember what this metric doesn't tell you: a perfectly formed call can still be the wrong plan, and correct arguments don't guarantee the right final answer. Pair it with trajectory evaluation (the sequence of calls) and end-to-end task success.

A description fix

Before: date: string. After: date: string, ISO 8601 (YYYY-MM-DD), resolve relative dates like "last Friday" using the provided current date. On the 25 date-heavy cases, argument accuracy rises from 56% to 88%.

Key takeaway: Slice by tool and argument, fix descriptions and schemas first, and re-run on every change.

How it works, step by step

Step 1 of 4
Eval design

1. Write expected calls

For each case define the expected tool and arguments (or acceptable sets), plus cases where no call is right.

issue_refund(order_id, reason)
Key numbers at this step
Include
ambiguous and negative

When to use it & trade-offs

What it is

Tool-call accuracy evaluates whether an agent or assistant calls the right tool, with valid and correct arguments, at the right time (and doesn't call tools when it shouldn't). It's broken into measurable parts: tool selection (right function chosen), argument correctness (schema-valid, values match what the user asked), call necessity (no redundant or hallucinated calls), and abstention (no call when the request needs a clarification or can't be served). Most of it can be checked deterministically against expected calls, which makes it the cheapest and most reliable eval in an agent stack.

Why it matters: Agents fail quietly at the tool boundary: a wrong function, a swapped argument, a date in the wrong format or an invented parameter produces wrong actions (or exceptions) downstream, and the final answer looks plausible. Tool-call evals localise those errors, are fast enough to run on every prompt, schema or model change, and catch the regressions that tool-description edits and model upgrades often introduce.

When to reach for it

  • Every change to prompts, tool descriptions, schemas or models
  • Choosing between models for agentic tasks
  • Finding which tools or parameters confuse the agent

When to avoid or be careful

  • Testing only the happy path
  • Comparing raw strings without normalising formats
  • Treating valid JSON as correct arguments

Ways to check tool use

Deterministic call matching
Best for: Selection, schema and structured arguments

Strengths: Cheap, exact and fast; pinpoints errors.

Watch out: Needs expected calls; brittle for multi-path tasks.

Sandbox outcome checks
Best for: Tasks with several valid call sequences

Strengths: Tests real effects.

Watch out: Needs realistic environments.

LLM judge on traces
Best for: Free-text arguments and plan quality

Strengths: Flexible.

Watch out: Noisier and costlier; needs validation.

Interview signals & numbers to know

When this topic comes up

  • “The agent called the wrong function”
  • “Dates are passed in the wrong format”
  • “Function-calling evals”
  • Strict schemas
  • Clarify versus guess

Benchmarks & rules of thumb

94% / 81% / 99% -
selection, argument and schema-valid rates in the example
81% → 90% -
argument accuracy gain from clearer descriptions
56% → 88% -
date-case accuracy after the description fix

Common mistakes & follow-ups

Common interview mistakes

  • Scoring a call as correct because the JSON validated, ignoring wrong values.
  • Never testing cases where the right action is to ask a question.
  • Not re-running tool evals after a model upgrade.

Likely interviewer follow-ups

  • How would you evaluate an agent's function calls?
  • How do you handle several valid sequences of calls?
  • What would you change if argument accuracy is low on one tool?
Interview tip: Quote per-tool numbers and the abstention rate. It shows you test the boundary where agents fail quietly, not only the final answer.
Loading hands-on exercise

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Tool Call Accuracy with generative AI interview Q&A and hands-on practice.

Open Generative AI Q&A →Tech Learn Q&A
Previous topic
Context Precision
Next topic
Trajectory Evals