Skip to content

Lesson 2 of 11 · 3 min read

Outcome and Trajectory Grading

Free lessonReviewed By the AIAgentInterviews editorial team
Reading position
In this lesson

TL;DR: First grade the outcome: compare the end state of the world with the expected state, because the agent can take many valid paths to the same correct result. Then grade the trajectory with invariants: things that must never happen (a write before verification, a forbidden tool), things that must happen (a confirmation before an irreversible step), and limits (steps, cost, time). Avoid exact-match against a reference trajectory. Use code wherever the property is checkable, and model graders only for what is not.

After this lesson, you should be able to design an outcome grader from expected end state, express trajectory requirements as invariants, explain why reference-path matching is brittle, and decide which checks need a model grader.

Before you read

Commit to an answer now. The lesson that follows explains it, and having guessed first, even wrongly, makes the explanation easier to remember.

  1. 1An eval compares each agent run against a recorded 'golden' sequence of tool calls. A new model version scores 20 points lower, but reviewers say its runs are as good or better. What is the likely problem?

Two things to grade

SAME RUN, TWO QUESTIONS
Did it get there, and did it get there acceptably?

Outcome grading

Snapshot state

seeded test database

Run the agent

any path it chooses

Diff end state

expected rows, files, messages

Outcome, safe: Robust to valid alternative paths

Trajectory invariants

Record the trace

every call and result

Check must-nots

no write before verify

Check musts and limits

confirmation, ≤ 12 steps

Outcome, safe: Catches right answers reached the wrong way

Outcome grading: check the world

Seed an environment (a test database, a sandbox repository, a mock mailbox), run the agent, and compare the end state with what should be true. τ-bench (Yao et al., 2024) graded customer-service agents this way, by comparing the final database state with the expected one.

  • Compare only what the task should change, plus what it must not change. A refund task should create one refund row of the right amount, and leave every other order untouched.
  • Normalise what does not matter: ids generated at run time, timestamps, whitespace in messages.
  • For outputs that are text (a reply to a customer), check the facts it must contain with code where you can (the refund amount, the order id) and leave tone and clarity to a calibrated model grader.

Trajectory grading: invariants, not a golden path

Some correct outcomes are still unacceptable: the refund was right but issued before the order was verified, or the task took forty calls when it needed eight. Those are properties of the path. State them as invariants rather than as a reference sequence:

def trajectory_problems(calls, max_steps=12):
    problems = []
    names = [c["tool"] for c in calls]
    if "refund_create" in names:
        first_write = names.index("refund_create")
        if "orders_verify" not in names[:first_write]:
            problems.append("refund before verification")
    if any(c["tool"] == "account_delete" for c in calls):
        problems.append("forbidden tool used")
    if len(calls) > max_steps:
        problems.append(f"{len(calls)} steps, limit {max_steps}")
    return problems

good = [{"tool": "orders_get"}, {"tool": "orders_verify"}, {"tool": "refund_create"}]
other_path = [{"tool": "orders_verify"}, {"tool": "orders_get"},
              {"tool": "refund_create"}]
bad = [{"tool": "orders_get"}, {"tool": "refund_create"}]
print(trajectory_problems(good), trajectory_problems(other_path))  # => [] []
print(trajectory_problems(bad))  # => ['refund before verification']

The second run reads in a different order from the first and passes, as it should. An exact-match grader would have failed it. The third run reaches a refund without verifying, which an outcome check alone would miss.

Who grades

PropertyGrader
End state of records, files, testsCode
Facts that must appear in a replyCode (match ids, amounts), then a model for paraphrase
Order constraints, forbidden actions, limitsCode over the trace
Clarity, tone, helpfulness of a replyModel grader with a rubric, calibrated on human labels
Whether a judgement call was reasonablePeople, sampled; or a calibrated model grader

Prefer code: it is free, deterministic and cannot be talked into a pass. Model graders are for what code cannot see, and they need calibration (see Calibrating an LLM Judge).

Say it in 30 seconds

"I grade outcomes by seeding an environment and diffing the end state against what should be true, which accepts any valid path; I grade trajectories with invariants (must-nots like a write before verification, musts like a confirmation, and limits on steps and cost) rather than matching a golden path, which penalises valid alternatives. Code checks everything it can, and calibrated model graders handle tone and judgement. Most evals need both: the right answer reached the wrong way still fails."

Check yourself

Answer aloud or on paper before revealing. Producing the explanation unaided is exactly what a panel listens for.

  1. 1Why should an outcome grader also check things the task must not change?

  2. 2Give an example of a correct outcome that should still fail an eval.

  3. 3When is a model grader appropriate in an agent eval?

Practise it as an interviewer asks it

Course lessons that teach this

Related lessons