How to evaluate an AI agent beyond its final answer
An assistant can say “done” after a failed tool call. Build an evaluation that checks what happened, not just whether the final sentence sounds convincing.
The assistant says, “Your reservation is confirmed.” It sounds right. But the tool returned an error and no reservation exists. An evaluation that reads only the last sentence may accept a failed run.
When a chat becomes an agent with tools, the unit of evaluation changes. Text still matters, but so do attempted actions, arguments and observed outcomes. This is a practical issue in current agent engineering: one successful demo cannot tell you whether a model or prompt change improves the system.
Start with a case you can judge
Consider an inventory assistant asked whether blue notebooks are available. It must query the requested SKU. It has no permission to reserve or purchase anything.
Write acceptance conditions before running it: query that product, obtain a successful result and attempt no write operations. Then add a check that the final answer agrees with the returned inventory.
Avoid requiring one exact sequence when several paths are valid. The assistant may need to search for the SKU before checking inventory. Fix the success conditions and action boundaries, rather than every intermediate step.
A small trace can expose real failures
A trace records observable steps in a run. Here we record tool names, arguments and result status. These are fictional local records: the example neither calls a model nor sends data to a service.
runs = {
"valid": [
{"tool": "get_stock", "sku": "BLUE", "ok": True},
],
"wrong_product": [
{"tool": "get_stock", "sku": "RED", "ok": True},
],
"unauthorized_action": [
{"tool": "get_stock", "sku": "BLUE", "ok": True},
{"tool": "reserve_stock", "sku": "BLUE", "ok": True},
],
"failed_lookup": [
{"tool": "get_stock", "sku": "BLUE", "ok": False},
],
}
def check_trace(events):
read_only = all(event["tool"] == "get_stock" for event in events)
found = any(
event["tool"] == "get_stock"
and event["sku"] == "BLUE"
and event["ok"] is True
for event in events
)
return read_only and found
for name, events in runs.items():
print(name, check_trace(events))valid True
wrong_product False
unauthorized_action False
failed_lookup FalseThe check rejects the wrong product, an unauthorized action and a failed lookup. It also rejects an empty trace. It does not yet check stock quantities or the final answer's truthfulness: passing only establishes these two trace conditions.
This example assumes well-formed records captured by the application. In a real system, validate their structure and record attempted calls before execution, not just successful operations. A trace invented by the model is not evidence of what happened.
Keep distinct questions separate
One average score can hide a serious failure. Keep these dimensions for each case:
| Dimension | Concrete question |
|---|---|
| Outcome | Does the answer agree with the observed state? |
| Tools | Did it query the right product and handle errors? |
| Permissions | Did it attempt anything the request did not authorize? |
| Budget | How many calls, how much time and what cost did it consume? |
Enforce permissions during execution. Evaluation after the fact detects failures; it does not prevent them. Good answers elsewhere should not compensate for a permission violation.
Compare changes against the same cases
Include normal, ambiguous and adverse cases: unknown products, missing SKUs, unavailable tools and malicious text inside returned data. Keep another set out of prompt tuning, so you do not simply optimize for familiar examples.
When comparing versions, preserve tool responses or control the environment. If inventory changes between runs, you may be measuring different inputs. Repeat cases when model behavior varies, and report successes over attempts alongside specific failures. Four fictional traces do not establish production reliability.
Traces need boundaries too
The Agents SDK tracing documentation describes recording generations, tool calls and other events. You need not use that SDK to apply this method, but it provides a concrete example of observable events.
Before enabling external trace collection, check what gets captured: prompts and results may contain personal data or credentials. Minimize and redact sensitive content before exporting it. Start with synthetic cases and manual failure review. A useful trace helps explain a failure, rather than merely producing another score.