Agent Evaluation Quickstart
In this quickstart you’ll evaluate an agent on two tasks, score its answers, and produce a run bundle with a browsable HTML report — all on your machine, with no platform services and no API keys. It takes about five minutes.
For the concepts behind tasks, trials, runners, and metrics, see Agent Evaluation. This page is the hands-on version.
Prerequisites
- Python 3.11–3.14
- The SDK:
Everything here runs in a single local Python process. You’ll swap the stand-in agent for a real model or deployed agent once you’ve seen the flow.
1. Define a metric
A metric scores one trial. It implements three things: a type (its name), an output_spec() (the
values it emits), and compute_scores() (the scoring logic). Here’s a tiny one that scores 1.0
when the agent’s answer contains an expected keyword and 0.0 otherwise. It reads the agent’s answer
from input.candidate.output_text and the task’s grader-only reference from input.row.data.
2. Define your tasks
Each AgentEvalTask is one unit of work: an intent, the inputs the agent acts on (here, an
instruction), a grader-only reference (held-out truth the agent never sees), and the metrics
that score this task. The intent is a human-readable note about the task’s goal — metadata for
whoever reads or maintains the suite. It is not passed to the agent, which only ever sees
inputs. Because metrics live on the task, different tasks can use different scorers.
3. Provide an agent
An agent is anything that turns a task into an answer. The simplest option is an async function; the
SDK provides a runner — CallableAgentTaskRunner — that wraps your function so it plugs into a run.
The runner hands your function the whole task and expects an answer back (here, a canned response
keyed by task id). We’ll use a stand-in so the quickstart runs with no external services; later
you’ll point the evaluation at a real model or a
deployed agent instead.
4. Run the evaluation
AgentEvaluator.run() sends the tasks to the runner, collects the trials, scores them, and returns
an AgentEvalResult. Setting output_dir also writes a run bundle to disk. (run() is async, so it
lives inside an async function — see the full script below.)
5. Read the results
run() returns an AgentEvalResult you can work with directly in Python:
result.summary— aggregated scores per metric output (the mean you just printed), plus coverage counts (how many trials were scored, failed, or missing an output).result.scores— one entry per (task, trial, metric): the metric outputs and their status.result.trials— each trial: the agent’s answer, the evidence it produced (trajectory, final state, logs), and its status (completed/partial/failed).result.run_id— a stable identifier for this run.
Because you set output_dir, the same data was also written to ./agent-eval-run/ as a run bundle:
The in-memory result and the on-disk bundle hold the same information: use the result object for
programmatic follow-up, and the bundle (especially report.html) to inspect or share a run.
Full script
Run it:
Expected output (both answers contain the expected keyword, so the mean is 1.0):
Open ./agent-eval-run/report.html to see the run in a browser.
Next steps
- Swap the stand-in agent for a real model or a deployed agent over HTTP.
- Add a trajectory metric that scores how the agent worked (its tool use), not just the answer.
- Give a task more than one metric, or combine metric outputs into a named view.