Agent eval is harder than chain eval because the path matters, not just the destination. Three layers:
1. Final-answer eval
Same as chain eval — task accuracy on a labeled set. Necessary but insufficient.
2. Trajectory eval
Did the agent take a sensible path?
- Did it call the right tools?
- Did it call them in a reasonable order?
- Did it stop at the right moment?
- Did it recover from errors?
Trajectory eval catches agents that happen to get the right answer wastefully (e.g., 30 tool calls for a 3-call task) and agents that get the right answer for the wrong reason.
How to do trajectory eval
- LLM-as-judge with a rubric: "Was the trajectory efficient? Did it call necessary tools?"
- Reference trajectories for a labeled subset; compare actual vs reference (edit distance, tool-overlap).
- Heuristics: tool-call count, redundancy, dead-ends.
3. Tool-call accuracy
- Precision: of tools the agent called, how many were necessary?
- Recall: of tools that should have been called, how many were?
- Argument shape: were arguments well-formed and semantically correct?
Real-world signals
- Cost per task — drift up = agent looping or over-calling.
- Latency p99 — drift up = pathological queries hitting iteration caps.
- Error rate from tools — if the agent hits errors more often, schemas may have drifted.
- User feedback — explicit and implicit (did they retry, rephrase, abandon?).
Eval tooling
- LangSmith — first-class trace inspection, dataset eval, online + offline.
- LangFuse — open-source equivalent with similar feature set.
- Phoenix Arize — open-source, strong trajectory visualization.
- Custom: store all traces, run nightly LLM-judge against a rubric, alarm on regressions.
The eval loop in production
- Log every trajectory (LangSmith / LangFuse).
- Sample failures and edge-case successes weekly.
- Add new edge cases to your eval set.
- Run eval on every prompt / model / tool change.
- Track cost-per-task and trajectory length as quality metrics, not just accuracy.
Why most teams skip this
It's tedious and offline accuracy is easier to optimize. But agents that pass offline eval and fail in production almost always fail on trajectory issues — looping, picking wrong tools, ignoring observations. Trajectory eval is what separates a demo from a system.