Assertions
An assertion grades what an eval's test(t) function produced. Each assertion records a result instead of throwing, so one run reports every failing assertion, not only the first. Check what the agent did with scoped methods, grade a value with t.check, or record your own measurement with t.score. For grading by a model, see Judge.
Scoped assertions
Scoped assertions take no value and are gates by default. Call them on t to check the whole run after test finishes. Call them on a session to check that session so far, or on a turn to check one reply. A run is parked when it stopped to wait on an approval or question that nobody answered (human-in-the-loop, or HITL, input).
| Assertion | Asserts |
|---|---|
t.succeeded() | The run did not fail and did not park on unanswered HITL input |
t.awaitingInput() | The run cleanly parked on HITL input |
t.messageIncludes(token) | Joined assistant text contains token (string or RegExp) |
turn.outputEquals(value) / .outputMatches(schema) | Deep equality or Standard Schema validation of turn/session structured output |
t.calledTool(name, opts?) | A matching tool call completed (input, output, status, count) |
t.calledSkill(skill, opts?) | A load of skill completed (output, status, count) |
t.notCalledTool(name) | No call to name, whatever its status |
t.toolOrder([...names]) | Tool requests appear in order |
t.usedNoTools() | No tool calls at all; skill loads don't count |
t.maxToolCalls(n) | At most n tool calls; skill loads don't count |
t.noFailedCalls() | No tool, subagent, or skill action reported a failure |
t.calledAgent(name, opts?) | A subagent delegation happened (identity, remote, output, status, count) |
t.event(type, opts?) / t.notEvent(type, opts?) | Typed event presence, data, and count matching |
t.eventOrder([...matchers]) | Matching event groups occur in order |
t.eventsSatisfy(label, predicate) | Escape hatch: any predicate over the typed event stream |
succeeded() passes when the session ended or is waiting for the next message. It fails when the run failed, an event reports an error, or the run is parked. Structured output assertions exist only on turns and sessions, where one output is unambiguous (see the output schema guide).
awaitingInput() passes whenever the run parked, whatever it waits for. To check what it waits for, select the open interactions from its view.
The same methods work on a single turn or on an attached session:
t.calledTool and t.usedNoTools are mutually exclusive; assert one or the other in a run.
A call through eve__tool is reported under the name and input of the tool it reaches, such as linear__list_issues. Assert on that tool. eve__search calls count toward t.usedNoTools() and t.maxToolCalls(n); skill loads don't.
The tool-name assertions and turn.requireToolCall throw a TypeError for eve__tool, eve__skill, and built-in names such as load_skill. The error says what to assert instead. eve accepts a name like load_skill when the root agent declares a tool by that name or has a dynamic tool resolver.
Assert on session state with selectors
Whenever an eval has a view and needs to know what is happening in the session, use selectors from eve/events. Read turn.view, session.view, or live.view, select the facts you need, and grade them with t.check, t.require, or t.score. These are the same selectors used in hooks, channels, dynamic capabilities, and clients, not an eval-specific API.
Keep scoped assertions such as turn.calledTool(...) when they already express the check. Selectors let you compose checks over calls, tasks, replies, interactions, usage, and other recorded state without rebuilding it from events. For example, this eval requires at least one task and checks that every observed task ended successfully:
Keep these scope rules in mind:
turn.viewis a snapshot of the whole session when the turn returned, not a view filtered to that turn. Filter by turn ID for turn-specific checks.activeTurnreturns only an open turn, so don't use it to find a completed one.- A view knows only the events its reader observed. Attaching at a later
startIndexcan omit the events that opened a call or request. - Each view belongs to one session. Run-level assertions on
tcan span several sessions; check each session's view separately.
See Session views & selectors for the full selector catalog and scope guarantees.
Check what a parked turn waits for
awaitingInput() checks that a run parked, not why. Select the open requests with openInteractions and check their kinds, associated calls, or answers. This eval passes when the turn finishes, or when it parks only on approvals for the deploy tool:
Keep the rows.length > 0 check: every passes on an empty list, and the list is empty when the eval didn't read the events that opened the requests. Open doesn't mean unanswered: a request can already have an answer while eve still processes it.
Value assertions with t.check
t.check(value, assertion) grades any value, such as a turn's .reply or parsed JSON, with a builder from eve/evals/expect:
| Builder | Scores | Default |
|---|---|---|
includes(value) | coerced string contains a substring or matches a RegExp | gate |
equals(value) | deep structural equality | gate |
matches(schema) | validates against a Standard Schema | gate |
similarity(expected) | normalized Levenshtein similarity, 1 = identical | soft |
satisfies(fn, label) | custom boolean predicate | gate |
For example, a failed labeled equality check prints:
Pick the cheapest builder that captures "correct". Use similarity when an exact match is too strict, and the judge for nuanced grading.
Scores with t.score
t.score(evaluation) records a score from 0 to 1. Pass a number, { score, message?, metadata? }, or a promise of either. Chain .label(key) to name it; reporters and artifacts show the label as key. Unlabeled scores all report as score.
A score without a rule doesn't affect the eval's outcome. Chain a rule when it should:
Reports show the measured score: a 0.82 gated at 0.9 reports score: 0.82, threshold: 0.9, passed: false. An evaluator that throws or returns a score outside 0 to 1 fails the eval. The result is marked errored, with the error message and no score.
Reporters receive the entries in onEvalComplete and can read them by key:
The same entries appear in the run artifacts under .eve/evals/, in summary.json and in one results.jsonl line per eval:
threshold and passed are present only when a rule was chained.
The matcher mini-language
t.calledTool and t.calledAgent take matcher objects:
| Matcher | Fields | status values |
|---|---|---|
calledTool | input, output, status, count | "completed" (default), "pending", "failed", "rejected" |
calledAgent | callId, childSessionId, output, status, count | "completed" (default), "pending", "failed", "rejected", "interrupted", "abandoned" |
A numeric count requires that exact number of calls matching every supplied constraint. For ranges, pass a predicate that receives the number of matching calls.
calledAgent matches each call to a subagent. A call is pending until it finishes, then takes its final status and, when completed, its output. A completed subagent keeps its session for later calls with the same taskId. childSessionId is absent when the call failed before the subagent's session opened. A subagent's approval or question doesn't change the call's status; assert it with requireInteraction.
Matcher values accept a literal (objects partial-deep-match), a RegExp, or a predicate function that returns a boolean:
requireInteraction finds an approval or question. It uses the same matchers for input, prompt, and display. Its optionIds matcher receives the option ids in order, and a literal array must match the whole list exactly:
Run state and derived facts
For custom checks about where the session stands, query a view with selectors. Use event assertions when an event's presence, payload, count, or ordering is itself the contract under test:
For a custom predicate over event-level information, use eventsSatisfy. For example, check that at least one content part streamed before it completed:
Assert and score reasoning
When the model provider exposes reasoning, eve records it as content.completed with kind: "reasoning". Select the blocks with parts, join their inline text, and grade it or pass it to a judge:
This reads reasoning across the snapshot; add a turnId or runId filter for a narrower check. Referenced values are not fetched by the selector. A provider that doesn't expose reasoning leaves the string empty, so the includes gate fails and the judge grades an empty string. The default judge input and session.transcript exclude reasoning, so pass it with on.
Required preconditions
Recorded assertions aren't awaitable. When later code depends on a value, use await t.require(value, assertion). It records a gate and returns the value when it passes. When it fails, it stops the test without reporting a second, duplicate error:
Use the matching require* lookups when later code needs a tool call or a pending request:
Severity
Every assertion returns a handle. Chain one of these to set its severity:
.gate(threshold?)is hard. A miss marks the evalfailedandeve evalexits non-zero..soft(threshold?)is recorded in reports. A miss below the threshold marks the evalscored, which fails the run only under--strict. With no threshold, it never fails..atLeast(threshold)is soft with a bar (equivalent to.soft(threshold))..label(key)adds a stable name when an eval records several assertions of the same kind. Braintrust and Datadog keep one score per name.eve evalwarns when soft assertions in one eval share a name but have different scores.
Scoped methods and includes, equals, matches, and satisfies are gates; similarity, t.judge(...), and t.score(...) are soft. Chain a severity only to change the default:
What to read next
- Judge: LLM-graded assertions with thresholds
- Cases: where assertions attach
- Running evals: how verdicts map to exit codes