scenario
Scenario files for Pipecat behavioral evaluations, of either kind.
A scenario describes one conversation to hold with a bot and how to judge it.
A file holds one or more of them under scenarios:, each with a name:,
and a scenario’s keys say which kind it is:
turns:a scripted scenario: the user’s turns are written out, each with the events expected back from the bot (
pipecat.evals.script).persona:a simulated scenario, a simulation for short: an LLM plays a caller with a goal, and a judge reads the whole conversation (
pipecat.evals.simulation).
Both carry the same user: and judge: blocks
(pipecat.evals.scenario_config). A file is read by a SafeLoader that
resolves only plain-decimal integers, so a DTMF 012 keeps its digits, with
an !include <path> tag that splices in another YAML file relative to the
including one, so files can share their user: and judge: blocks.
Any key a scenario can have may also sit at the top of the file. There it is
the default for every scenario in the file. A scenario that sets the same key
replaces the whole value; nothing is merged, so a context: is written out in
full, never added to. A scenario is named <file name>/<scenario name>.
Most files hold one scenario. A file holds several when they test one behavior through many short conversations:
name: turn_completion
judge: !include ../judge_text.yaml
context:
- role: system
content: "You are a travel assistant."
scenarios:
- name: short_answer
turns:
- user: "Japan."
expect:
- event: response
- name: with_history
context: # replaces the file's context
- role: system
content: "You are a travel assistant."
- role: assistant
content: "Where would you go?"
turns:
- user: "Japan."
expect:
- event: response
turns: and persona: may sit at the top too. That is for a file whose
scenarios hold the same conversation and differ in one thing only. Two common
shapes:
The same turns, judged differently. The turns are written once, and each scenario names its own judge or modality, so every judge sees exactly the same conversation:
name: interruption
turns:
- user: "Tell me a long story about Paris."
expect:
- event: llm_started
- user: "Actually, what's the capital of Japan?"
send_after: {event: llm_started, delay_ms: 2000}
expect:
- event: bot_interrupted
- event: response
eval: "says Tokyo instead of continuing the story"
scenarios:
- name: text
judge: !include ../judge_text.yaml
- name: audio
user: !include ../user_audio.yaml
judge: !include ../judge_audio.yaml
The same caller, with different goals. The persona and what counts as success are written once, and each scenario gives the caller a different errand:
name: diner
persona: "Jamie, calling a restaurant. Friendly and to the point."
success: "the bot did what the caller asked and confirmed it"
scenarios:
- name: book
goal: "Book a table for two at 6 PM tonight, then end the call."
- name: cancel
goal: "Cancel tonight's booking under the name Jamie, then end the call."
The scenarios of a file are independent: each runs on its own, against its own bot.
Deprecated since version 1.11.0: Use a scenarios: list instead of a scenario’s own keys (turns: or
persona:) at a file’s top level. Such a file still loads, as that one
scenario under the file’s name:, with a DeprecationWarning. Will be
removed in 2.0.0.
This module gathers the public names of both kinds, EvalScenarioFile
loads a file as the scenarios it holds, and is_scenario_file() tells a
scenario from a fragment it includes.
- class pipecat.evals.scenario.EvalConfigured(*args, **kwargs)[source]
Bases:
ProtocolThe modality and service config a scenario and a simulation share.
- class pipecat.evals.scenario.EvalKind(*values)[source]
Bases:
StrEnumThe two kinds of scenario, as a run, a session, and a results record name them.
- SCRIPT = 'script'
- SIMULATION = 'simulation'
- class pipecat.evals.scenario.EvalExpectation(event: str, within_ms: int | None = None, text_contains: str | None = None, text_excludes: str | None = None, text_matches: list[str] | None = None, calls: list[EvalFunctionCall] | None = None, eval: str | None = None, marker: str | None = None, marker_first: bool | None = None, markers: int | None = None, text_after: bool | None = None, check_from: str = 'previous', absent: bool = False)[source]
Bases:
objectA single expected event in a scenario turn.
- Parameters:
event – Required — the semantic event name (e.g.
user_stopped_speaking).within_ms – Optional latency budget, measured from the turn’s user send — all of a turn’s expectations share that one anchor, so a stalled turn fails within a single budget rather than one per expectation. For audio turns the anchor is when the utterance was sent, not when it finishes streaming to the bot. Defaults to 60s when omitted, so timing isn’t asserted unless set explicitly.
text_contains – Optional substring check on the event’s text content (
llm_response.textoruser_transcription.transcript).text_excludes – Optional substring the event’s text content must not hold. Checked on the text the expectation matched; with
text_contains, on the reply accumulated up to the match.text_matches – Optional regular expressions (
re.search) the event’s text content must each match, checked on the same text astext_excludes.calls – For a
function_callevent, the set of calls expected in the turn. They are matched by name in any order and the expectation passes only when all of them are found. Built fromcalls:in the YAML, or from the singlename:/args:shorthand.eval – Optional natural-language criterion the event’s text content must satisfy. Evaluated by a judge LLM. Meaningful on the bot-generated text events (
response,llm_response,tts_response, and theexpressionits TTS performed) and on the function-call events, where it is about each matched call’s name and arguments rather than text.marker – For an
llm_markerevent, the meaning the marker must have: one ofMARKER_KINDS, whereincompleteacceptsshortorlong.marker_first – For an
llm_markerevent, whether the first marker in the response’s raw text must come before any text.markers – For an
llm_markerevent, how many markers the response’s raw text must hold.text_after – For an
llm_markerevent, whether text must (True) or must not (False) follow the first marker in the raw text.check_from – Where the expectation checks for its event from:
previous(the default), where the expectation above it was met; orturn_start, the beginning of the turn, at events the expectations above it did not use.absent – When True, the expectation is inverted: it passes only when NO event of this type arrives before the
within_msbudget expires, and fails as soon as one does. Matches on event type only;text_contains,text_excludes,text_matches,eval,callsand the marker checks are not allowed alongside it.
- calls: list[EvalFunctionCall] | None = None
- class pipecat.evals.scenario.EvalFunctionCall(name: str | None = None, args: dict | None = None)[source]
Bases:
objectOne expected function call within a
function_callexpectation.- Parameters:
name – The function name to match.
Nonematches any call (used by a barefunction_callexpectation that just asserts a call happened).args – Optional subset check on the call’s arguments (every listed key/value must be present; extra arguments are ignored).
- class pipecat.evals.scenario.EvalScenario(**kwargs)[source]
Bases:
EvalScriptScenarioDeprecated alias for
EvalScriptScenario.Deprecated since version 1.9.0: Use
EvalScriptScenarioinstead. Will be removed in 2.0.0.
- class pipecat.evals.scenario.EvalScenarioFile(name: str, path: Path, scenarios: list[EvalScriptScenario | EvalSimulationScenario])[source]
Bases:
objectA scenario file: what it is called, where it is, and the scenarios it holds.
Manifests and
pipecat eval runload files throughload(), so the two kinds of scenario mix in one list.file[name]picks a scenario by its<file name>/<scenario name>.- Parameters:
name – The file’s
name:.path – The file it was read from.
scenarios – The scenarios it holds, in file order.
- classmethod load(path: str | Path) EvalScenarioFile[source]
Read a scenario file, parsing each scenario as whichever kind it is.
A file in the deprecated shape, a scenario’s own keys at the top level and no
scenarios:, loads as that one scenario under the file’sname:and warns.- Parameters:
path – Path to a scenario YAML file.
- Returns:
The loaded file.
- Raises:
ValueError – If the file is malformed, or a scenario is neither kind, claims to be both, or is invalid for its kind.
FileNotFoundError – If the path doesn’t exist.
- class pipecat.evals.scenario.EvalScriptScenario(name: str, turns: list[~pipecat.evals.script.EvalScriptTurn], context: list[dict] = <factory>, judge: dict = <factory>, bot_audio: bool = False, transcriber: dict | None = None, user_audio: bool = False, user_speech: dict | None = None, trigger_disconnect: bool = False, stop_on_failure: bool = True, source_path: ~pathlib.Path | None = None)[source]
Bases:
objectA parsed scenario file.
- Parameters:
name – The eval name (from
name:).turns – Ordered list of turns.
context – LLM messages the bot’s context should start from for this eval. When non-empty, the harness sends them as an
eval-contextclient message right after the bot-ready handshake (the eval serializer turns it into anLLMMessagesUpdateFrame, which replaces the context); bots without an LLM context aggregator ignore the frame. Omitted or empty (the default): the harness sends nothing and the bot keeps the context it set up itself.judge – Judge LLM configuration dict with keys
service,model, optionalendpoint, and an optionalextramapping forwarded to the model as top-level request parameters. Defaults to{"service": "ollama", "model": "gemma4:12b", "extra": {"reasoning_effort": "none"}}.bot_audio – Whether the bot produces speech, derived from
judge.modality. False (text, the default): the bot skips TTS — the harness configures skip-TTS at connect, so even an on-connect greeting is silent. True (audio): the bot speaks, and the judge evaluates the transcription of its actual audio.transcriber – Parsed from the
judge.transcription:block; the STT config (servicedefaults tomoonshine, plusmodeland an optionallanguagecode) used to transcribe the bot’s audio for theresponseevent (Nonein text modality). Setlanguagewhen the bot speaks a non-English language so the STT doesn’t default to English.user_audio – Whether the user’s turns reach the bot as speech, derived from
user.modality. False (text, the default): each turn is sent as an RTVIsend-text. True (audio): the harness streams RTVIraw-audio, exercising the bot’s STT for real.user_speech – Parsed from the
user.speech:block; the TTS config the harness synthesizes user turns with (Nonein text modality). Mapping withservice,voice, and optionalmodel/language/speed/sample_rate/api_key. Setlanguage(a code likezh) to synthesize non-English user turns.trigger_disconnect –
Whether a bot serving the server
EvalTransportfires itson_client_disconnectedhandler when this scenario’s connection ends.Deprecated since version 1.13.0: No replacement. A bot fires
on_client_disconnectedwhenever the harness disconnects. Will be removed in 2.0.0.stop_on_failure – Whether the first failed turn ends the scenario (default True). A failed turn leaves the conversation in an unknown state, so continuing usually costs one timeout per remaining turn. Set False for a scenario whose turns are scored independently, where the turns after a failure are still worth driving; each turn’s outcome is reported in
turns. This governs turn-to-turn progression only: within a turn, an expectation that times out still ends that turn’s matching, because a turn’s expectations share one deadline anchored at the send.source_path – Path the scenario was loaded from, for error messages.
- classmethod load(path: str | Path) EvalScriptScenario[source]
Parse a YAML file holding a scenario’s own keys at its top level.
Deprecated since version 1.11.0: Use
load()instead. Will be removed in 2.0.0.- Parameters:
path – Path to a YAML file with the scenario schema.
- Returns:
The parsed scenario.
- wants_response() bool[source]
Whether any expectation asserts on the transcription of the bot’s audio.
- required_report_level() str | None[source]
The function-call report level the scenario’s assertions need:
fullfor args,namefor names, elseNone.A call with an
eval:needsfulltoo: the judge is asked about the call’s arguments.
- needs_vad_events() bool[source]
Whether the scenario uses the raw VAD speaking events, which the bot emits only on request.
- class pipecat.evals.scenario.EvalScriptTurn(user: str | None, expect: list[EvalExpectation] = <factory>, parts: list[str | int] | None = None, audio: str | None = None, dtmf: str | None = None, send_after: EvalSendAfter | None = None, image: str | None = None)[source]
Bases:
objectOne turn in a scenario.
A turn drives the bot one of three ways: the harness sends a
userutterance (the person speaks), it sends adtmfkeypress sequence (the person presses keys), or it is observation-only (neither field — useful for bot-first scenarios like opening greetings).useranddtmfare mutually exclusive: a turn is one or the other.A
userturn is spoken by the harness’s TTS unless the turn names anaudiofile to play instead.- Parameters:
user – Optional text the harness sends as the user’s turn — an RTVI
send-textin text modality, or synthesized speech (raw-audio) in audio modality. If absent, the turn just waits for and asserts on expected events.parts – The turn’s text and pauses, in order, when it pauses: text to speak, or the milliseconds of silence between texts.
userthen holds the text alone. Requiresuser.modality: audio.audio – Optional path to an audio file (resolved relative to the scenario file) played as this turn instead of synthesizing
user. Any formatsoundfilereads works (WAV, MP3, FLAC, OGG, …); multi-channel audio is downmixed to mono.useris required alongside it and is what the recording says — the judge reads it as the turn’s input andtext_containsmatches against it, neither of which can be recovered from the audio. Requiresuser.modality: audio, and is mutually exclusive withdtmf.dtmf – Optional DTMF keypad sequence the harness sends, one
InputDTMFFrameper character (e.g."123#"). Each character must be a validKeypadEntry(0-9,*,#). Mutually exclusive withuser. The keys are injected the same way regardless of the scenario’s user/judge modality; a bot with aDTMFAggregatorturns them into a transcription it reacts to. Quote the value in YAML (dtmf: "123#") — an unquoted#starts a comment.expect – Expected events, in the order they should arrive. Optional — omit it for a pure pacing/observation turn (e.g. a
dtmfturn that only presses keys, with the assertion on a later turn).send_after – Optional schedule for when the turn’s input should fire. Only meaningful when
userordtmfis set.image – Optional path to an image to register for this turn (resolved relative to the scenario file). When a function-calling-video bot requests a user image during the turn, the eval transport serves this one. Stays registered until a later turn provides a different image.
- send_after: EvalSendAfter | None = None
- class pipecat.evals.scenario.EvalSendAfter(event: str | None, delay_ms: int)[source]
Bases:
objectScheduling for when a turn’s input (
userordtmf) is sent.When set on a
EvalScriptTurn, the harness waits foreventto have been seen (either earlier in the run or arriving now), then waits an additionaldelay_msbefore sending the turn’s input. Used for barge-in tests:send_after: {event: llm_started, delay_ms: 500}means “interrupt 500ms after the bot started responding.”eventis optional: a baresend_after: {delay_ms: 500}is a pure time delay with no event anchor (500ms after the previous turn’s send). Handy for pacing keypresses acrossdtmfturns, where there is no per-key event to anchor on.- Parameters:
event – Name of the event to schedule from, or
Nonefor a puredelay_mstime delay with no event anchor.delay_ms – Additional delay in milliseconds after the event was received (or, when
eventisNone, after the previous turn’s send).
- class pipecat.evals.scenario.EvalSimulationMetric(name: str, criterion: str | None = None, min_score: float | None = None, measure: str | None = None, min_value: float | None = None, max_value: float | None = None, calls: list[EvalFunctionCall] | None = None)[source]
Bases:
objectA quality metric: a judged criterion, or a measure with a range or a call list.
- Parameters:
name – The metric’s name in the results.
criterion – What the judge decides on each bot turn;
Nonefor a measured metric.min_score – The share of the bot’s turns the judge must answer yes for, in 0..1, below which a judged metric fails the run;
Nonereports the score without gating.measure – One of
SIMULATION_MEASURES;Nonefor a judged metric.min_value – The measured value’s lower bound, inclusive, or
None.max_value – The measured value’s upper bound, inclusive, or
None.calls – For
function_calls, the calls the bot should make: each a name, or a name withargsas a subset of the call’s arguments; an empty list means none.Nonefor every other metric.
- calls: list[EvalFunctionCall] | None = None
- class pipecat.evals.scenario.EvalSimulationScenario(name: str, persona: str, goal: str, success: str, simulator: dict = <factory>, metrics: list[EvalSimulationMetric] = <factory>, judge: dict = <factory>, bot_audio: bool = False, transcriber: dict | None = None, user_audio: bool = False, user_speech: dict | None = None, max_turns: int = 20, max_duration_s: float = 300.0, max_silence_s: float = 30.0, runs: int = 1, trigger_disconnect: bool = False, source_path: Path | None = None)[source]
Bases:
objectA parsed simulation file.
- Parameters:
name – The simulation name (from
name:).persona – Who the caller is, as free text for the persona LLM.
goal – What the caller wants from the call.
simulator – The persona LLM config (
service,model, optionalendpoint/extra), the same shape asjudge.eval; empty for the default local model.success – What counts as the bot having done its job, for the judge.
metrics – The judged quality criteria.
judge – Judge LLM config, as for a scenario.
bot_audio – Whether the bot speaks (
judge.modality: audio).transcriber – STT config for the bot’s audio in audio modality, else None.
user_audio – Whether the persona’s turns reach the bot as speech (
user.modality: audio).user_speech – TTS config the persona’s turns are synthesized with in audio modality, else None.
max_turns – Cap on the persona’s turns.
max_duration_s – Cap on the run’s wall clock, in seconds.
max_silence_s – Cap on a lull with no event from either side, in seconds.
runs – How many times the suite runs the simulation; every run must pass.
trigger_disconnect –
Whether a bot serving the server
EvalTransportfires itson_client_disconnectedhandler when the connection ends.Deprecated since version 1.13.0: No replacement. A bot fires
on_client_disconnectedwhenever the harness disconnects. Will be removed in 2.0.0.source_path – Path the simulation was loaded from, for error messages.
- classmethod load(path: str | Path) EvalSimulationScenario[source]
Parse a YAML file holding a simulation’s own keys at its top level.
Deprecated since version 1.11.0: Use
load()instead. Will be removed in 2.0.0.- Parameters:
path – Path to a YAML file with the simulation schema.
- Returns:
The parsed simulation.
- class pipecat.evals.scenario.EvalTurn(**kwargs)[source]
Bases:
EvalScriptTurnDeprecated alias for
EvalScriptTurn.Deprecated since version 1.9.0: Use
EvalScriptTurninstead. Will be removed in 2.0.0.
- pipecat.evals.scenario.describe_config(scenario: EvalConfigured, *, color: bool = False) str[source]
Two-line summary of a scenario’s user + judge config, for pre-run logs.
- Parameters:
scenario – The parsed scenario to summarize.
color – When True, ANSI-color each segment’s keyword by category (modality, service, judge LLM) so they’re easy to tell apart.
- Returns:
A
userline and ajudgeline, each a set ofkey: valuesegments separated by|, e.g.:user -> modality: audio | speech: kokoro/af_heart judge -> modality: audio | transcription: moonshine/small-streaming | eval: ollama/gemma4:12b
- pipecat.evals.scenario.describe_simulation(simulation: EvalSimulationScenario, *, color: bool = False) str[source]
Three-line summary of a simulation’s user config, judge config, and goal, for pre-run logs.
The lines of
describe_config(), theuserline also naming the persona LLM that plays the user and the run’s caps, then the caller’s goal, e.g.:user -> modality: text | persona: ollama/gemma4:12b | max_turns: 8 | max_duration_s: 120 | max_silence_s: 30 judge -> modality: text | eval: ollama/gemma4:12b goal -> Book a table for two at 6 PM, then end the call.
- Parameters:
simulation – The parsed simulation to summarize.
color – When True, ANSI-color the keywords as
describe_configdoes.
- Returns:
The summary, one line per section.
- pipecat.evals.scenario.is_scenario_file(path: str | Path) bool[source]
Whether a YAML file is a scenario of either kind, rather than a fragment one includes.
Every scenario has a
name:; an included fragment has none. A file that does not parse counts as a scenario, so loading it reports the error instead of a directory run skipping it silently.- Parameters:
path – Path to a YAML file.
- Returns:
True unless the file parses to a mapping without a
name.
- pipecat.evals.scenario.load_scenario_file(path: str | Path) EvalScriptScenario | EvalSimulationScenario[source]
Load a file holding one scenario, as whichever kind it is.
Deprecated since version 1.11.0: Use
EvalScenarioFile.load()instead, which returns every scenario a file holds. Will be removed in 2.0.0.- Parameters:
path – Path to a scenario or simulation YAML file.
- Returns:
The parsed scenario.
- Raises:
ValueError – If the file holds several scenarios, or is invalid.