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.

Rahul Bisht

Founder, CrawlPilot

·
Nov 24, 2026
·
Verified Nov 24, 2026
·AI & Agents·
18 min read
·
How to Evaluate LLM Agents: A Practical Guide to Eval Testing
Key takeaway
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.

Six words every eval guide uses

Anthropic's January 2026 post Demystifying evals for AI agents has the clearest glossary, and the other vendors' docs map onto it.

run k timesTaskinput and successTrialone run of the agentTranscriptevery step and tool callOutcomestate the run leftGraderscode, model or personScoreper task and per suite
An eval runs a task several times and grades both the transcript and the outcome
TermMeaningIn the refund example
TaskOne test case: an input plus success criteria"Refund order #1042, which arrived damaged"
TrialOne attempt at a task. You run several because results varyFive runs of that task
Transcript (trace, trajectory)The record of a trial: messages, reasoning, tool calls and their resultslookup_order, then check_refund_policy, then a reply
OutcomeThe state of the environment when the trial endsWhether a refund row exists
GraderLogic that scores one aspect of a trial"Refund amount equals the order total"
Eval suiteA set of tasks that share a goal40 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.

Code, a model, or a person: picking the grader

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.

GraderHow it worksGood atWeak at
CodeString and regex matches, unit tests, database queries, checks on tool callsFast, cheap, repeatable, easy to debugFails 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 outputsOpen-ended text, tone, whether a summary is faithfulCosts more, varies between runs, has to be checked against people
PersonDomain experts review transcripts, label samples, run A/B testsCatches what nobody thought to write a check forSlow 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:

  1. 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."
  2. 02
    Grade one dimension per call. Anthropic runs a separate judge for each thing it checks instead of one long rubric.
  3. 03
    Let the judge say it doesn't know. Anthropic gives judges an "Unknown" answer for transcripts that don't contain enough evidence.
  4. 04
    Ask for the reasoning before the verdict, and watch for the judge preferring longer answers or whichever answer it saw first (OpenAI).
  5. 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.

Did it finish, how did it get there, and how often

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:

MetricPasses when
Exact matchThe calls exactly mirror the reference sequence
In-order matchEvery required call appears in order; extra calls are allowed
Any-order matchEvery required call appears, in any order
PrecisionMost of the agent's calls are in the reference (few wasted steps)
RecallMost of the reference calls were made (few missed steps)
Single-tool useOne 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

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.

Offline before you ship, online after

Offline evalsOnline evals
WhenOn every change, before release, like CI testsAfter release, on live traffic
DataA fixed dataset with known success criteriaReal sessions, usually with no reference answer
GradersCode checks first, model judges where neededMostly model judges, plus user feedback and alerts
QuestionDid 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
  1. Each task in the dataset starts a fresh sandbox, so no trial sees another's leftovers.
  2. Code checks and model judges score every trial, and someone reads a sample of the failing transcripts.
  3. The change ships only if the regression suite still passes and the capability suite moved the right way.
  4. In production, a model judge scores a sample of real conversations, and alerts and user feedback flag the rest.
  5. 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.

Building a first suite for the refund agent

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.

Start with 20 to 50 real failures

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.

Write tasks two experts would grade the same way

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-001 input: "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: true refund_amount: 59.00 - id: refund-out-of-window-002 # should decline politely input: "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: false must_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.

Give every trial a clean environment

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.

Layer the graders

python
def grade(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 is not None) == 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" not in 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 k trials, then read the failures

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.

Close the loop

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.

Where Anthropic, OpenAI, Google, LangChain and Braintrust differ

The method is shared. The emphasis isn't, and each one is worth borrowing.

CompanyTheir termsWhat to borrow
AnthropicTasks, trials, graders, transcripts, outcomesGrade outcomes over paths, report pass^k for consistency, start from real failures, read transcripts
OpenAIEval-driven development, trace gradingGrade whole traces (model calls, tool calls, guardrails, handoffs) while debugging, then move to datasets; "Evaluate early and often"
Google CloudFinal response and trajectory evaluationSix named trajectory metrics you can compute without a judge
LangChain / LangSmithOffline and online evaluation, datasets, experimentsScore a single step, the final response or the full trajectory; turn production traces into dataset rows
BraintrustEnd-to-end and single-step scorersScore 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.

Six ways an eval suite lies to you

ProblemWhat you seeFix
Trusting the agent's wordsThe reply says "refund issued" and nothing happenedCheck the outcome in the database or environment
Over-strict path checksA valid route to the goal is marked as a failureGrade outcomes; check only the steps that matter in themselves
One run per taskA lucky run hides how unreliable the agent isRun k trials and report pass^k for user-facing agents
Vague judge scoresScores drift and nobody agrees what a 7 meansPass or fail questions, one judge per dimension, checked against human labels
Leaky environmentsTrials see each other's leftovers and scores inflateA fresh sandbox and data for every trial
A saturated suiteEverything passes, so you learn nothing about progressMove easy tasks to regression and keep adding harder ones

Check yourself

Check yourself

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?

The short version

Cheat sheet
Evaluating LLM agents

Graders

  • Code where you can, a model judge where you can't, people to check both.
  • Judges answer narrow PASS, FAIL or UNKNOWN questions, one dimension per call.
  • Compare the judge with human labels before trusting it.

What to measure

  • The outcome first: check the state of the world, not the reply.
  • Path checks only for rules that must never break.
  • pass^k for user-facing agents, pass@k when someone picks the best attempt.
  • Cost, turns and latency next to quality.

The suite

  • Start with 20 to 50 tasks from real failures, including ones to refuse.
  • A reference solution per task; a fresh sandbox per trial.
  • Capability suites start low; regression suites sit near 100%.

The loop

  • Run offline evals on every prompt, tool or model change.
  • Score sampled production traffic after release.
  • Every confirmed failure becomes a new task.
  • Read the transcripts before trusting a number.

Sources