Skip to content
mentoor

Topic 2 of 6 · 5 min read

Judging agent trajectories step by step

Goal: Review an agent trajectory and name the step that wasted effort or should have changed course.

A trajectory is the full record of what an agent did, step by step, and reading it shows problems that a pass or fail result hides.

Check yourself · 1 of 3

An agent reaches the right answer, but its log shows 14 steps where 5 would do. What does grading only the outcome miss?

Choose one answer

Why it matters

Two agents can both fix a bug. One does it in 6 steps. The other reads the same file five times, runs a failing command four times and succeeds by luck on the ninth step. The end-state grade is the same. The cost, the latency and the odds of failing tomorrow are not. Anthropic's guidance on agent evals recommends reading transcripts for exactly this reason: you learn whether a failure is the agent's fault or the grader's.

How to read one

  1. Log every step. Keep the model's message, each tool call with its arguments, each result and a timestamp.
  2. Find the first wrong turn. The failure you see at step 20 often started at step 4, when the agent misread a result and carried on.
  3. Look for loops. The same call with the same arguments twice, with the same error, is a loop.
  4. Check recovery. When a tool returned an error, did the agent change something, or retry blindly?
  5. Check order. Did it write before it read? Did it edit before reproducing the bug?
  6. Decide what to grade. Grade only the outcome when many paths are fine. Grade the path when order is a rule, such as "verify identity before changing an account", or when cost matters.

You can automate parts: count steps, flag repeated identical calls, and set a step budget that fails the run when exceeded.

Before and after

step 3  run_tests            -> 2 failed
step 4  run_tests            -> 2 failed
step 5  run_tests            -> 2 failed
step 6  read_file auth.py

The agent re-ran the tests three times without changing anything. The fix is a rule in the harness or prompt: after a failing result, read the failure before acting again. The grader gains a check for repeated identical calls.

What goes wrong

  • Only looking at failures. Passing runs can hide waste and luck.
  • Grading the path too tightly. A required sequence punishes valid shortcuts.
  • Blaming the model first. A tool that returns a vague error causes loops too.

Examples

Three identical test runs

An agent runs the same failing test command at steps 3, 4 and 5 and changes nothing between them. The outcome grader still passes it at step 12. A trajectory check on repeated calls would flag the waste.

Order as a rule

A banking agent must confirm identity before changing an address. One run changes the address first and confirms afterwards. The end state is correct, but the order broke policy, so this task needs a path grader.

Key points

  • A trajectory records every message, tool call, argument and result in order.
  • Find the first wrong step, because later failures often trace back to it.
  • Repeated identical calls and blind retries after errors are signs of a loop.
  • Grade the path when order is a rule or cost matters; otherwise grade the outcome.
  • Step and cost budgets turn wasteful runs into measurable failures.

Common mistakes

  • Reading only failed runs and never passing ones.
  • Requiring one exact sequence of steps for tasks with many valid routes.
  • Blaming the model for loops caused by an unclear tool error message.
  • Keeping only the final message and discarding intermediate steps.

Check yourself · 2 of 3

A trajectory fails at step 20. Where should you start reading?

Choose one answer

Check yourself · 3 of 3

When is it right to grade the path rather than only the outcome?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic