The AgentSession manages the orchestration of the voice pipeline. Key configuration options include:
stt: Speech-to-text provider (the agent's 'ears').tts: Text-to-speech provider (the agent's 'voice').turn_handling: Controls how the agent detects when a user has finished speaking and how it handles interruptions.turn_detection: Uses a TurnDetector to analyze acoustic and semantic cues.interruption: Set mode="adaptive" to distinguish between real interruptions and backchannels (like "mhm").preemptive_generation: Set enabled=True to allow the LLM to start generating a response while waiting for the end of a turn.
expressive: When set to True, the LLM can emit inline delivery tags (emotion, pacing) that supported TTS models (like Fish Audio) will render.
session = AgentSession(
stt=inference.STT(model="assemblyai/universal-3-5-pro", language="en"),
tts=inference.TTS(model="fishaudio/s2.1-pro", voice="fa4c9eb3dccc4806b382b40d61c6b10a"),
turn_handling=TurnHandlingOptions(
turn_detection=inference.TurnDetector(),
interruption={"mode": "adaptive"},
preemptive_generation={"enabled": True},
),
expressive=True,
)