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: Protocol

The modality and service config a scenario and a simulation share.

user_audio: bool
user_speech: dict | None
bot_audio: bool
transcriber: dict | None
judge: dict
class pipecat.evals.scenario.EvalKind(*values)[source]

Bases: StrEnum

The 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: object

A 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.text or user_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 as text_excludes.

  • calls – For a function_call event, 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 from calls: in the YAML, or from the single name:/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 the expression its 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_marker event, the meaning the marker must have: one of MARKER_KINDS, where incomplete accepts short or long.

  • marker_first – For an llm_marker event, whether the first marker in the response’s raw text must come before any text.

  • markers – For an llm_marker event, how many markers the response’s raw text must hold.

  • text_after – For an llm_marker event, 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; or turn_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_ms budget expires, and fails as soon as one does. Matches on event type only; text_contains, text_excludes, text_matches, eval, calls and the marker checks are not allowed alongside it.

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
property aggregates: bool

Whether the check accumulates text across events rather than matching one.

A reply with a content check accumulates the bot’s segments, and an expression check the expression performed in the turn; a user_transcription with text_contains accumulates an STT’s pieces.

class pipecat.evals.scenario.EvalFunctionCall(name: str | None = None, args: dict | None = None)[source]

Bases: object

One expected function call within a function_call expectation.

Parameters:
  • name – The function name to match. None matches any call (used by a bare function_call expectation 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).

name: str | None = None
args: dict | None = None
property signature: str

name(arg=value, ...).

Type:

A short label for the call

class pipecat.evals.scenario.EvalScenario(**kwargs)[source]

Bases: EvalScriptScenario

Deprecated alias for EvalScriptScenario.

Deprecated since version 1.9.0: Use EvalScriptScenario instead. Will be removed in 2.0.0.

class pipecat.evals.scenario.EvalScenarioFile(name: str, path: Path, scenarios: list[EvalScriptScenario | EvalSimulationScenario])[source]

Bases: object

A scenario file: what it is called, where it is, and the scenarios it holds.

Manifests and pipecat eval run load files through load(), 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’s name: 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: object

A 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-context client message right after the bot-ready handshake (the eval serializer turns it into an LLMMessagesUpdateFrame, 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, optional endpoint, and an optional extra mapping 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 (service defaults to moonshine, plus model and an optional language code) used to transcribe the bot’s audio for the response event (None in text modality). Set language when 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 RTVI send-text. True (audio): the harness streams RTVI raw-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 (None in text modality). Mapping with service, voice, and optional model / language / speed / sample_rate / api_key. Set language (a code like zh) to synthesize non-English user turns.

  • trigger_disconnect –

    Whether a bot serving the server EvalTransport fires its on_client_disconnected handler when this scenario’s connection ends.

    Deprecated since version 1.13.0: No replacement. A bot fires on_client_disconnected whenever 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.

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: Path | None = None
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: full for args, name for names, else None.

A call with an eval: needs full too: 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.

needs_bot_images() → bool[source]

Whether the scenario asserts on the images the bot outputs, which it reports only on request.

needs_marker_events() → bool[source]

Whether the scenario asserts on the LLM’s markers, 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: object

One turn in a scenario.

A turn drives the bot one of three ways: the harness sends a user utterance (the person speaks), it sends a dtmf keypress sequence (the person presses keys), or it is observation-only (neither field — useful for bot-first scenarios like opening greetings). user and dtmf are mutually exclusive: a turn is one or the other.

A user turn is spoken by the harness’s TTS unless the turn names an audio file to play instead.

Parameters:
  • user – Optional text the harness sends as the user’s turn — an RTVI send-text in 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. user then holds the text alone. Requires user.modality: audio.

  • audio – Optional path to an audio file (resolved relative to the scenario file) played as this turn instead of synthesizing user. Any format soundfile reads works (WAV, MP3, FLAC, OGG, …); multi-channel audio is downmixed to mono. user is required alongside it and is what the recording says — the judge reads it as the turn’s input and text_contains matches against it, neither of which can be recovered from the audio. Requires user.modality: audio, and is mutually exclusive with dtmf.

  • dtmf – Optional DTMF keypad sequence the harness sends, one InputDTMFFrame per character (e.g. "123#"). Each character must be a valid KeypadEntry (0-9, *, #). Mutually exclusive with user. The keys are injected the same way regardless of the scenario’s user/judge modality; a bot with a DTMFAggregator turns 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 dtmf turn 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 user or dtmf is 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.

parts: list[str | int] | None = None
audio: str | None = None
dtmf: str | None = None
send_after: EvalSendAfter | None = None
image: str | None = None
class pipecat.evals.scenario.EvalSendAfter(event: str | None, delay_ms: int)[source]

Bases: object

Scheduling for when a turn’s input (user or dtmf) is sent.

When set on a EvalScriptTurn, the harness waits for event to have been seen (either earlier in the run or arriving now), then waits an additional delay_ms before 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.”

event is optional: a bare send_after: {delay_ms: 500} is a pure time delay with no event anchor (500ms after the previous turn’s send). Handy for pacing keypresses across dtmf turns, where there is no per-key event to anchor on.

Parameters:
  • event – Name of the event to schedule from, or None for a pure delay_ms time delay with no event anchor.

  • delay_ms – Additional delay in milliseconds after the event was received (or, when event is None, 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: object

A 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; None for 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; None reports the score without gating.

  • measure – One of SIMULATION_MEASURES; None for 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 with args as a subset of the call’s arguments; an empty list means none. None for every other metric.

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
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: object

A 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, optional endpoint / extra), the same shape as judge.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 EvalTransport fires its on_client_disconnected handler when the connection ends.

    Deprecated since version 1.13.0: No replacement. A bot fires on_client_disconnected whenever the harness disconnects. Will be removed in 2.0.0.

  • source_path – Path the simulation was loaded from, for error messages.

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
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: EvalScriptTurn

Deprecated alias for EvalScriptTurn.

Deprecated since version 1.9.0: Use EvalScriptTurn instead. 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 user line and a judge line, each a set of key: value segments 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(), the user line 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_config does.

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.