Evaluating agent trajectories
Why grading only an agent's final answer misses forbidden actions, skipped checks and loops; how to score a trajectory on outcome, required and forbidden tool calls, ordering and efficiency; state-based checks; LLM judges for trajectories; and how to build a trajectory test set. With runnable code that shows final-answer grading passing runs that should fail.
By Sandip Maity, Applied AI Engineer
An agent's final message is the last line of a long story. Between the user's request and that message, the agent may have called the wrong tool, acted on the wrong record, skipped a required check, or looped ten times. Grading only the final answer misses all of it. This lesson shows how to grade the whole trajectory.
#What a trajectory contains
A trajectory is the ordered record of a run: the user input, each model turn, each tool call with its arguments and result, and the final answer. If you trace your agent (tracing), you already have it; evaluation reads the same data.
Pro content
Keep reading with Inference Academy Pro
Unlock the rest of this lesson, plus every advanced lesson, hands-on lab, the larger playground models and completion certificates.
Still to come in this lesson
- Five things to score
- State checks versus path checks
- LLM judges for trajectories
- Non-determinism
- Building a trajectory test set
- Common mistakes
- Exercises
You will be able to answer
- An agent refunds the right order but first refunds the wrong one by mistake. Final-answer grading says...
- Which trajectory checks should be hard fails, whatever the outcome?
- Why compare final state (the database after the run) rather than only the tool-call list?
- An agent passes but uses 6 tool calls where 2 are enough. How should that be reported?
- Agents are non-deterministic. How many runs per task should you use?