Multi-Turn Conversations
This recipe shows how to script a voice scenario with multiple back-and-forth turns, and
how to configure the JudgeAgent to verify the agent maintains conversational continuity
across turns — not just that individual replies are coherent, but that the second reply
builds on the context of the first.
Pattern
Each scenario.user() / scenario.agent() pair is one turn. Repeat the pair for
each scripted exchange, then call scenario.judge() at the end.
script=[
scenario.agent(), # agent's opening greeting (turn 1)
scenario.user("Hello, I have a question about my account."),
scenario.agent(), # agent's reply to turn 1
scenario.user("What information do you need from me to look it up?"),
scenario.agent(), # agent's reply to turn 2 — must reference turn 1 context
scenario.judge(),
],
max_turns=6,Asserting continuity
The JudgeAgent only evaluates what you put in criteria. For multi-turn scenarios,
add an explicit continuity criterion that pins the second reply to the first exchange:
scenario.JudgeAgent(
criteria=[
"The agent greeted the user naturally",
"The agent offered help in a friendly tone",
# Continuity: the second reply must make sense in context of turn 1.
"The agent's second reply addresses the user's follow-up question coherently",
]
)Worked example
basic_greeting.py
— a clean 2-turn greeting flow: agent greets, user responds, agent follows up; judge
checks naturalness and that audio turns exchanged.
accent_loop.py
— a 3-turn scripted loop where the user spells their name across turns; demonstrates
multi-turn scripting with a persona-driven user simulator.
See also
- Capability matrix — adapter support for multi-turn state
- Interruption recipe — layering interrupts into multi-turn flows
- Observability recipe — per-turn latency metrics
