Compares the tool calls in a sample's trace with an expected trajectory.
{Nous.Eval.Scorers.Trajectory,
expected: [
%{name: "search_orders", args: %{"order_id" => "123"}},
%{name: "issue_refund"}, # any arguments
%{name: "notify", count: {1, 2}} # one or two calls
],
mode: :superset,
forbid: ["delete_all"]}Expected entries
Each entry is a map with name (required), args (a map, or :any;
absent means any arguments) and count (n, {min, max}, [min, max]
or %{"min" => _, "max" => _}; default 1). Matching is multiset: two
search entries need two search calls.
Modes
| Mode | Passes when |
|---|---|
:superset (default) | every expected call was made; extra calls allowed |
:subset | every call made was expected; expected calls may be missing |
:unordered | the calls are exactly the expected multiset, in any order |
:in_order | the expected calls appear in order; other calls may be interleaved |
:strict | the calls are exactly the expected ones, in order |
Order-free modes use a maximum bipartite matching, so a wildcard entry
listed before a specific one never steals the call only the specific
entry could match. Ordered modes use a dynamic program. Calls the model
requested in one response (one batch, which may run in parallel) are
compared order-free within the batch; parallel: :as_emitted compares
them in emitted order.
Options
:expected- the entries (required; may be empty only for:strict,:unorderedand:subset, or with:forbid):mode- see above (default:superset):args-:subset(default; recursive for maps, positional for lists),:exact,:ignore, or a function(actual, expected -> boolean)(Elixir only):args_overrides- per-toolargsmode, or a list of the only keys to compare:%{"issue_refund" => :exact, "search" => ["order_id"]}:ignore_args- top-level argument keys dropped on both sides;*globs ("*_cursor"):arg_defaults- per-tool defaults stripped when equal:%{"search" => %{"page" => 1}}:numbers-:exact(==, so1matches1.0; default) or{:tolerance, abs: a, rel: r}(%{"tolerance" => %{"abs" => a}}in files):include- which call outcomes count (default[:executed];:allor a list, seeNous.Eval.Trace.ToolCall):scope-:root(default),:treeor{:sub_agent, template}(%{"sub_agent" => template}in files):forbid- tool names that fail the sample when called at all, in any outcome (an attempt counts even if a hook denied it):parallel-:unordered_within_batch(default) or:as_emitted:score-:binary(default; value:pass | :fail) or:f1(a float: 1/0 for:strict, F1 of precision and recall for:in_orderand:unordered, recall for:superset, precision for:subset;0.0on a forbidden call).passed?follows the mode either way.
Enum values may be given as strings ("in_order") in dataset files.
Truncated traces
When the trace was truncated, a result that depends on calls being
absent (a failure, :strict/:unordered/:subset, or :forbid) is a
:missing_trace error rather than a verdict.
Details
matched (%{expected: index, tool_call_id: id}), missing (expected
entries short of calls), unexpected (calls no entry matched),
out_of_order (ordered modes: missing entries that a call did match, out
of order), arg_mismatches (%{expected:, tool_call_id:, paths:}, the
argument paths that differ for the nearest same-name call) and
forbidden.