Session 9 · Week 5 · Tue 11 Aug 2026 · 90 min

Grade the journey, not just the answer.

A right answer reached the wrong way will fail on the next input. For agents, the trajectory, which tools, in what order, on what context, is the thing to measure. Tonight: how to evaluate a non-deterministic system on purpose.

Ehsan Gazar
Production-Ready Systems with LLMs and Agents · session 9 of 12
Where we're going · 90 minutes

The run sheet.

0–12Why you can't ship on vibesnon-determinism needs evals
12–35Output vs trajectory evalsgrade the whole path
35–55How to graderules, LLM-judge, human
55–75Offline sets + online evalsand the flywheel
75–85Live: write three casesfor your system
85–90Recap + Project 4 previewharness next
You’ll leave able to explain why output-only checks miss agent failures, design a trajectory eval, choose a grader and name its trap, and run the flywheel that turns failed production traces into eval cases.
The reframe

You can't unit-test a probability.

Traditional tests assert exact outputs. The model returns a distribution, so "assert equals" doesn't apply. Evals replace it: a graded suite that tells you whether a change made the system better on average, and where it regressed. No evals means shipping on vibes.

Change a prompt → 🤞
"looks better in my three tries"
vibes
Change a prompt → run evals
"pass rate 84% → 91%, these 4 regressed"
evidence
Why outputs aren't enough

The answer can be right for the wrong reasons.

Grade only the final answer and you miss the agent that got lucky, called an expensive tool it didn't need, looped five extra times, or reached the answer via a path that won't generalize. For agents you grade the trajectory.

Output eval
is the final answer correct? Necessary, not sufficient for agents.
Tool-calling eval
did it call the right tools, with the right args, in a sane order?
Trajectory eval
was the whole path efficient, safe, and generalizable?
What a trajectory eval inspects

Score every step, not just the last.

flowchart LR
  G["Task"] --> S1["Step 1
right tool?"] S1 --> S2["Step 2
needed?"] S2 --> S3["Step 3
right args?"] S3 --> A["Answer
correct?"] A --> SC{"Score:
done · efficient · safe"} classDef s fill:#DCEBFE,stroke:#1F2937,color:#0E1726; classDef sc fill:#D6F5E3,stroke:#1F2937,color:#0E1726; class S1,S2,S3 s; class SC sc;

A trace, the recorded sequence of steps, is the raw material. No traces (S8's blind spot), no trajectory evals. That's why Thursday builds tracing.

The metrics that matter

Four dials on every eval run.

Task completion
did it actually achieve the goal? The headline number.
Tool-calling accuracy
right tools, right args, right order; no needless calls.
Cost & latency
tokens and time per task; a "correct" run that costs 10× is a regression.
Safety
did injection tests get through? Did it over-reach? From S8, now measured.
A case is just data

The eval Air Canada didn't run.

One case that asserts the model grounds its answer instead of inventing policy. Run it on every change and the "liable for a made-up refund" bug never ships.

# one eval case · support assistant
{
  "input": "refund for BA-2490, you cancelled it",
  "expect_tool": "lookup_policy",          # trajectory: must check policy
  "expect_contains": "carrier-cancellation",   # output: cites the clause
  "must_not": "state a refund amount not in policy",
  "grader": "rule + llm_judge"
}
Who does the grading

Three graders, each with a trap.

1
Rules / code
exact match, schema, "did it call tool X?" Cheap, reliable. Trap: only works for checkable facts.
2
LLM-as-judge
a model scores nuance against a rubric. Scales to fuzzy quality. Trap: biased, needs its own validation.
3
Human
the gold standard for judgment. Trap: slow and costly, so reserve it and sample.

Use rules where you can, LLM-judge where you must, and humans to calibrate the judge. Never trust an LLM judge you haven't checked against people.

Two arenas

Offline sets gate releases. Online evals watch prod.

Offline · the golden set
a curated suite of cases with known-good outcomes. Run on every change, before you ship. Your regression gate.
pre-ship
Online · sampled traffic
grade a slice of real production runs continuously. Catches what your golden set never imagined.
in-prod

You need both. Offline tells you a change is safe to ship; online tells you the real world agrees.

The compounding advantage

Every failure in prod becomes a permanent test.

This is the loop that separates teams that improve from teams that thrash. A bad trace in production isn't just an incident, it's a new eval case that guarantees the same failure never ships again.

flowchart LR
  P["Prod trace fails"] --> C["Capture it"]
  C --> E["Add to eval set"]
  E --> F["Fix + re-run evals"]
  F --> S["Ship, regression locked out"]
  S --> P
  classDef ok fill:#D6F5E3,stroke:#1F2937,color:#0E1726;
  class E,S ok;
        
Don't confuse them

Guardrails block at runtime. Evals measure over time.

Guardrail

A live check that blocks a bad action now, output validation, an injection filter, an approval gate. Protects this one request.

Eval

An offline or sampled measurement of quality across many runs. Tells you if the system is getting better or worse.

Together

Guardrails keep today safe. Evals make tomorrow better. A serious system runs both, and red-teams the guardrails in the evals.

The mistake

Shipping guardrails and calling it "tested." A blocked action isn't a measured quality. You still need the suite.

Your turn · ~10 min

Write three eval cases.

For your system: one happy-path case, one hard/edge case, and one safety case (an injection attempt from S8). Each with an input and what "pass" means. Drop your safety case in the chat.

1
Happy path
typical input, clear correct outcome
2
Hard case
the edge that breaks naive versions
3
Safety case
injection must be refused
Recap · then Thursday

Grade the path. Gate on it. Grow it from prod.

Output evals aren't enough, grade the trajectory: completion, tool-calling, cost, safety. Rules where you can, LLM-judge where you must, humans to calibrate. Offline gates releases, online watches prod, and every failure becomes a permanent case.

Thursday · S10 workshop
Build the harness: tracing, dashboards, prompt versioning, human-in-the-loop. Output: Project 4 + runbook completed.
due Sun Aug 16
Bring
your three eval cases. Thursday they become a real harness.
take-home