Score by Component
The quickstart scored one thing: whether the final answer contained the right keyword. But an agent can reach the right answer the wrong way — guessing instead of looking something up, or looping on a tool. Agent evaluation lets you score how the agent worked, not just the outcome, and combine several signals into one reported view.
This guide extends the quickstart. You’ll add a trajectory metric that reads the agent’s tool
calls, keep the quickstart’s outcome metric, and combine them into a quality view. It stays
zero-dependency — one local process, no API keys.
This builds on the quickstart’s
KeywordMatchMetric and tasks. The full runnable script is at the end.
1. The outcome metric
Reuse the quickstart’s KeywordMatchMetric — it scores the final answer, reading it from
input.candidate.output_text and the grader-only truth from input.row.data:
2. A trajectory metric
A metric can read more than the final output. input.candidate.evidence exposes the trial’s
evidence — for the trajectory, an Agent Trajectory Interchange Format (ATIF) trace of the
agent’s steps. evidence.trace(...) gives a handle whose tool_calls() returns the tool calls in
order; each ToolCall has a function_name and arguments. This metric scores 1.0 when the agent
used the tool you expected and 0.0 otherwise:
The metric checks for evidence first — a trial without a trace simply scores 0.0 rather than
erroring.
3. Produce a trajectory
Runners that execute the agent capture this evidence for you — a
deployed HTTP agent returns a
trajectory when you set trajectory_path, and container/harness backends record one as the agent runs.
(A Harbor run scores a verifier reward
instead.) Here the agent is a local callable, so it returns a TrialDraft — its final output plus,
when it used a tool, a small ATIF trace built from the SDK’s trajectory models. One task’s agent uses the search tool; the
other skips it and just guesses, returning no trace at all:
4. Combine the signals into a view
Attach both metrics to each task, then define a view — a named roll-up of this task’s metric
outputs. SemanticView reduces its signals (each a metric.output) into one score; MEAN averages
them. The view is reported per task and aggregated across the run as view.<name>.
5. Run it and read the components
Output:
This is the whole point of scoring by component. The outcome looks perfect — every answer was
correct (1.0). But the trajectory metric shows only half the agents actually used the expected
tool (0.5); the other got the right answer by guessing. The view combines the two into a single
quality score (0.75) you can track over time. Scoring only the answer would have hidden the
shortcut entirely.