How to Evaluate LLM Agents: A Practical Guide to Eval Testing
What Anthropic, OpenAI, Google, LangChain and Braintrust agree on about testing AI agents: tasks and trials, the three kinds of grader, outcome versus trajectory, pass@k versus pass^k, offline and online evals, and a first suite you can build this week.
An agent eval runs a task several times in a clean environment and grades what changed in the world, then how the agent got there. Check outcomes with code, use a calibrated model judge only for what code can't see, report pass^k when users need consistency, and send every production failure back into the test set. Anthropic, OpenAI, Google, LangChain and Braintrust describe this same loop in different words.
The transcript ends with the agent writing "Your refund of $59.00 is on its way." The customer is happy, the conversation scores well with a model judge, and the payments table has no row for order #1042. The agent called check_refund_policy, read the result, and then wrote a reply as if it had called issue_refund too. A test that reads only the agent's last message passes this run. A test that queries the database fails it.
That gap between what an agent says and what it did is the reason agent evals look different from the prompt tests most teams start with. Anthropic's engineering team describes teams without them as "flying blind", and the rest of the field agrees on most of the method. Below are the parts they agree on, where they differ, and a first suite for a refund agent that you can adapt.
Anthropic's January 2026 post Demystifying evals for AI agents has the clearest glossary, and the other vendors' docs map onto it.
An eval runs a task several times and grades both the transcript and the outcome
Term
Meaning
In the refund example
Task
One test case: an input plus success criteria
"Refund order #1042, which arrived damaged"
Trial
One attempt at a task. You run several because results vary
Five runs of that task
Transcript (trace, trajectory)
The record of a trial: messages, reasoning, tool calls and their results
lookup_order, then check_refund_policy, then a reply
Outcome
The state of the environment when the trial ends
Whether a refund row exists
Grader
Logic that scores one aspect of a trial
"Refund amount equals the order total"
Eval suite
A set of tasks that share a goal
40 tasks on refunds, cancellations and escalations
Two more terms come up constantly. The agent harness is the code that turns a model into an agent: the loop, the tools and the prompts. When you evaluate "an agent" you are evaluating the model and its harness together, so a prompt change and a model upgrade both need the same suite. The eval harness is the test runner that starts trials, records transcripts, runs graders and adds up the scores.
LangChain's agent evals FAQ sums up the order of preference in one line: "Use code evaluators where you can, LLM judges where you can't, and human review to check both." Anthropic and OpenAI's evaluation best practices recommend the same order.
Grader
How it works
Good at
Weak at
Code
String and regex matches, unit tests, database queries, checks on tool calls
Fast, cheap, repeatable, easy to debug
Fails valid answers it didn't anticipate; can't judge tone or reasoning
Model (LLM as judge)
A second model scores against a rubric or a reference answer, or picks the better of two outputs
Open-ended text, tone, whether a summary is faithful
Costs more, varies between runs, has to be checked against people
Person
Domain experts review transcripts, label samples, run A/B tests
Catches what nobody thought to write a check for
Slow and expensive; doesn't scale to every commit
Model judges are where most suites go wrong, and the vendors' advice on them overlaps almost completely:
01
Ask narrow questions. LangChain: "A binary pass or fail, or a small set of labeled categories, is far more reproducible than scoring on a 1-10 scale."
02
Grade one dimension per call. Anthropic runs a separate judge for each thing it checks instead of one long rubric.
03
Let the judge say it doesn't know. Anthropic gives judges an "Unknown" answer for transcripts that don't contain enough evidence.
04
Ask for the reasoning before the verdict, and watch for the judge preferring longer answers or whichever answer it saw first (OpenAI).
05
Label a sample of transcripts yourself and check that the judge agrees with you before you rely on it. Recheck when the rubric, the judge model or the agent changes.
Our eval platform design covers how to measure that agreement and how far published judge studies say you can trust it.
An agent can be graded at three levels. Most good suites use all of them, with different weights.
The first is the outcome. Google's agent evaluation announcement frames final response evaluation as one question: "does your agent achieve its goals?" For an agent that acts on the world, the answer lives in a database, a file or a page, and the agent's reply is only its claim about that state.
The second is the trajectory, the sequence of tool calls. Google's Vertex AI ships six standard trajectory metrics that compare the agent's calls with a reference list:
Metric
Passes when
Exact match
The calls exactly mirror the reference sequence
In-order match
Every required call appears in order; extra calls are allowed
Any-order match
Every required call appears, in any order
Precision
Most of the agent's calls are in the reference (few wasted steps)
Recall
Most of the reference calls were made (few missed steps)
Single-tool use
One named tool was used somewhere in the run
Strict path metrics punish agents for finding routes you didn't write down. Anthropic describes a τ2-bench flight-booking task its own model "failed" by finding a policy loophole that got the user a better result. Their advice is to grade the outcome and enforce only the steps that matter in themselves.
Grade the outcome
Accepts any valid route to the refund
Catches the agent that claims success without acting
Misses a correct result reached by breaking a rule
Grade the exact path
Enforces ordering rules such as policy before payment
Fails creative but valid solutions
Breaks whenever you add or rename a tool
vs
Verdict: Grade outcomes everywhere and add path checks only for rules that must never break.
Grading the outcome versus grading the exact path, on the same refund task
The third level is reliability. Agents sample their way through a task, so one run proves little. Run each task k times and pick the metric that matches your product. pass@k is the chance that at least one of k tries succeeds, which suits a coding assistant where a developer picks the best attempt. pass^k is the chance that all k tries succeed, which suits a support agent, because every customer gets one try.
Single try75%
pass@3 (any of three passes)98%
pass^3 (all three pass)42%
One agent with a 75% success rate per try, scored two ways over three tries (Anthropic's example; pass@3 = 1 − 0.25³, pass^3 = 0.75³)
The same agent looks nearly perfect on one number and unreliable on the other. Track cost and speed next to these scores as well: tokens, tool calls, turns and wall-clock time per task. A prompt that adds two points of pass rate and doubles the token bill may not be worth shipping.
Mostly model judges, plus user feedback and alerts
Question
Did this change make things better or worse?
What is breaking that nobody wrote a test for?
LangChain puts the relationship plainly: "You need both, and they feed into each other." The LangSmith docs describe the same loop as adding real traces to a dataset "so a failure you saw once becomes a test you run every time." Braintrust's agent guide recommends scoring every production request at first, then sampling, and pulling both very low and suspiciously high scores back into offline tests.
12release gate34sampled traces4new test cases5Datasetreal tasks and criteriaRun trialsk per task in a sandboxGrade and readscores and transcriptsShipif nothing regressedProductionreal usersTriagejudges, alerts, feedback
Each task in the dataset starts a fresh sandbox, so no trial sees another's leftovers.
Code checks and model judges score every trial, and someone reads a sample of the failing transcripts.
The change ships only if the regression suite still passes and the capability suite moved the right way.
In production, a model judge scores a sample of real conversations, and alerts and user feedback flag the rest.
Every confirmed failure becomes a new task in the dataset, so it is tested on every future change.
≡
5 steps. Press Play to walk through them, or click any part of the diagram.
The eval loop, from dataset to production and back
Anthropic splits the offline side into two suites with opposite targets. Capability evals ask what the agent can do well and should start with a low pass rate, so there is room to improve. Regression evals ask whether it still does everything it used to and should sit near 100%, where any drop blocks a release. A capability task that the agent passes reliably moves into the regression suite. A suite where everything passes stops telling you anything about progress, so keep adding harder tasks.
No single layer catches everything. Anthropic compares the setup to the Swiss cheese model from safety engineering: automated evals before launch, production monitoring for drift, A/B tests for large changes, and a regular read through sampled transcripts and user feedback for the failures nobody predicted.
The agent handles refund requests with three tools: lookup_order, check_refund_policy and issue_refund. The steps follow Anthropic's roadmap. The code is illustrative Python rather than any one vendor's SDK.
Anthropic's starting point is "20-50 simple tasks drawn from real failures", pulled from support tickets, bug reports and whatever you already check by hand before a release. LangChain suggests 10 to 20 examples per behaviour. Early changes tend to have large effects, so a small set is enough to see them.
If two people who know refund policy could disagree about whether a run passed, the task is ambiguous. Include cases where the agent should decline, or you will only learn whether it refunds too rarely.
yaml
-id: refund-damaged-001input:"My order #1042 arrived broken. I want my money back."setup:{order:1042,total:59.00,delivered_days_ago:3,status: damaged }expect:refund_issued:truerefund_amount:59.00-id: refund-out-of-window-002# should decline politelyinput:"Refund order #2210 please, I just don't like it."setup:{order:2210,total:120.00,delivered_days_ago:95,status: delivered }expect:refund_issued:falsemust_not_call:[issue_refund]
Write a reference solution for each task and confirm it passes your graders. A task that scores 0% over many trials usually has a broken task definition or grader, and Anthropic found several of those in public benchmarks. In one, a grader rejected the answer 96.12 because it expected 96.124991.
Each trial gets a fresh database and sandbox. Shared state produces failures that move together and scores that look better than they are. Anthropic found Claude reading git history left behind by earlier trials.
defgrade(task, trial): db = trial.environment.db
scores ={}# Code: check the outcome in the database, not the reply refund = db.query("SELECT amount FROM refunds WHERE order_id = ?", task.order) scores["outcome"]=(refund isnotNone)== task.expect.refund_issued
if refund and task.expect.refund_amount: scores["amount"]=abs(refund.amount - task.expect.refund_amount)<0.01# Code: the one ordering rule that must never break calls =[c.name for c in trial.transcript.tool_calls] scores["policy_first"]=("issue_refund"notin calls
or("check_refund_policy"in calls
and calls.index("check_refund_policy")< calls.index("issue_refund")))# Model: one narrow question, with a way to say "unknown" scores["reply"]= llm_judge( transcript=trial.transcript, question="Is the final reply polite, clear about next steps and free of ""invented policy? Answer PASS, FAIL or UNKNOWN.",)return scores
The database query carries most of the weight and catches the refund from the opening of this post. The ordering check enforces policy before payment. The model judge handles only the reply's tone and accuracy, which code can't check.
Run each task five times and report pass rate and pass^5 for each grader, next to cost per task. When version B beats version A overall but breaks the ordering rule on a few runs, that is a regression and it blocks the release. Before you trust a small difference between versions, read the section on sample sizes in our platform post: a few points on 100 tasks is often noise.
Then read the transcripts. Anthropic's post ends with that instruction, "Read the transcripts!", because a score tells you that something changed and only the transcript tells you why.
After release, score a sample of live conversations with the same reply judge. Every failure that support or the judge confirms becomes task 51, 52 and so on.
Score the agent "both as a whole" and "at each individual step"; sample production adaptively
OpenAI's trace grading guide and the multi-agent notes in its best practices go further than the others on handoffs: whether each agent hands control over, and back, at the right moment. Its getting started page also says the hosted Evals product is being deprecated, so check its status before you build on the dashboard. The method carries over to any tool.
Q1Your support agent succeeds on 75% of single tries. Which number tells you how often a customer who asks three times gets a correct answer every time?
Q2The agent's reply says the refund was issued. What should the main grader check?