Evaluate an AI Agent: Trajectories, Tool Calls and an LLM Judge
Hosted · ide
Beta

Evaluate an AI Agent: Trajectories, Tool Calls and an LLM Judge

Build the evaluation harness for a tool-using agent: record its trajectories on a golden set, grade final answers deterministically, score tool trajectories with exact, in-order and any-order matching plus precision and recall, check tool arguments, add an LLM judge with an order-swapped pairwise mode, measure the judge's agreement with human labels, run the suite into a report, and gate a prompt change on per-case regressions rather than the aggregate score.

80 min8 steps3 domainsIntermediate
Part of the AI Engineer Course

Hands-on labs require Pro · $29.99/mo · cancel anytime

What you'll learn

  1. 1
    Record trajectories and read what an agent leaves behind
    The system under test is agent.py, a finished tool-using agent for
  2. 2
    Grade the final answer without a model
    The four eval shapes lecture makes the ordering explicit: anything with a
  3. 3
    Score the tool trajectory against a reference plan
    Two runs can produce the same correct number by different routes. One
  4. 4
    Check the arguments, not just the tool names
    Calling the right tool with the wrong arguments is the failure trajectory
  5. 5
    An LLM judge for the open part, with the order swapped
    Numbers, required phrases and tool paths are graded for free. What is left
  6. 6
    Calibrate the judge against human labels
    The pyramid in the eval-shapes lecture works in one direction: humans
  7. 7
    Run the suite into a report
    Four graders and a judge, each answering one question about one case. The
  8. 8
    Gate the prompt change on per-case regressions
    The regression-tests lecture describes the trap exactly. A change fixes

Prerequisites

  • Python: dicts, lists, json, regular expressions, a few lines of arithmetic
  • The module's evaluation lectures: the four eval shapes, LLM-as-judge and its biases, regression tests for prompts
  • Helpful: the tool-loop lab, whose finished agent is the system under test here

Exam domains covered

Agent EvaluationEvaluation and MLOpsTool Calling and Agents

Skills & technologies you'll practice

This intermediate-level ai/ml lab gives you real-world reps across:

Agent EvaluationLLM EvaluationLLM-as-a-JudgeTool CallingGolden SetRegression TestingAI Agents

Why agents need their own evaluation

A single-turn model is graded on its answer. An agent is graded on its answer and on how it got there: which tools it called, in what order, with what arguments, in how many steps, and whether it stopped on a budget. A correct number reached without the lookup is a guess that will be wrong next week, and a right path that ends in a wrong number is a prompt problem. The harness in this lab scores both, with the cheap deterministic shapes where an answer is closed and a model judge where it is open. The recordings are real. The baseline trajectories come from a hosted Llama 3.3 70B model driving the agent over the golden set, failures included: on one case the model wrote its tool call out as text and never called anything. The candidate prompt is a shorter rewrite that reads fine in review. The final step compares the two per case, the way a golden-set regression test does, and the difference between the aggregate and the per-case view is the lesson.

Frequently asked questions

What is the difference between evaluating an LLM and evaluating an agent?

An agent produces a trajectory as well as an answer: the tools it called, the arguments, the order, the step count. Agent evaluation scores the trajectory against a reference plan alongside the final answer, because a right answer reached the wrong way does not generalise.

How do you score a tool trajectory?

Against a reference plan with a matching mode: exact (same tool list), in-order (the reference appears as a subsequence, with partial credit), or any-order (the reference multiset is covered). Tool-selection precision and recall and a count of extra calls complete the picture; the lab implements all of them.

When should an LLM judge be used instead of exact matching?

Only for the open-text part of an answer. Numbers, required phrases and tool paths are graded deterministically, which is cheaper and cannot be biased. The judge grades against a rubric, pairwise comparisons run in both orders to expose position bias, and its scores are checked against human labels before they are trusted.

Why compare prompts per case instead of by average score?

Because an aggregate nets improvements against regressions. A candidate prompt can raise the pass rate while breaking cases users rely on. The gate in this lab lists every case that flipped and fails on any regression in a protected case.