Skip to main content

Overview

Flow and count assertions verify the behavior of an agent — which tools it called, in what order, how many times, and with what arguments.

Assertions reference

assert_called

Tool was called at least once:

assert_never_called

Tool was never called:

assert_called_before

Tool a was called before tool b (positional ordering across all turns):

assert_called_times

Tool was called between min and max times:

assert_called_with

Tool was called with specific argument values (partial match):
Matches if any call to the tool includes the specified arguments. Extra arguments are allowed. If no call matches, the error message shows the closest mismatch.

assert_tool_succeeded

Tool was called and every execution succeeded (no error in any result):

assert_max_turns

Trace has at most n turns:

assert_total_duration_under

Total trace duration is under a threshold (milliseconds):
Uses wall clock time for active sessions.

Flow patterns

assert_flow matches the ordered sequence of tool calls against a pattern. Patterns support ... (Ellipsis) for “any number of calls here”:

How anchoring works

Patterns are anchored to start and end by default:

Full example