matcher
Matching a scenario’s expectations against the bot’s events.
ExpectationMatcher waits on the run’s
EvalEventStream for the event an expectation
names and verifies it: a payload check, a judge verdict, the aggregation of a
reply across its segments, the any-order matching of a turn’s function calls,
and the inverted absent: check.
- class pipecat.evals.matcher.ExpectationMatcher(*, stream: EvalEventStream, judge: EvalJudge | None, trace: EvalTrace)[source]
Bases:
objectMatches one expectation at a time against the event stream.
Expected events must appear in order, with unmatched events allowed in between. A reply with a content check aggregates its segments and re-checks on each, so an interim “Let me check” is rolled past rather than taken for the answer. A turn’s function calls match by name in any order.
- __init__(*, stream: EvalEventStream, judge: EvalJudge | None, trace: EvalTrace)[source]
Initialize the matcher.
- Parameters:
stream – The bot’s events, consumed as expectations match.
judge – The judge for
eval:assertions, orNonewhen the scenario has none.trace – The run’s trace, for the matcher’s progress.
- async match(expectation: EvalExpectation, anchor: float, budget_ms: int, turn_idx: int, exp_idx: int) EvalAssertionFailure | None[source]
Wait for the expected event and verify it.
Stale bot output is not filtered here: the stream drops it on an interruption and the driver before each send.
- Parameters:
expectation – The expectation to match.
anchor – Monotonic time the turn’s budget is measured from.
budget_ms – The expectation’s latency budget.
turn_idx – Index of the turn, for the failure record.
exp_idx – Index of the expectation within the turn, for the record.
- Returns:
The failure, or
Nonewhen the expectation is satisfied.- Raises:
TimeoutError – When no matching event arrives at all (so the caller can report “no matching event arrived”). A response that arrives but never satisfies the content check returns a failure instead.
EvalBotEndedError – When the bot ends the call before the expectation is met. An
absent:expectation is met instead, since the event can no longer arrive.