how does On user turn completed hook behave with m...
# ask-ai
b
how does On user turn completed hook behave with multiple non-agent participants?
✅ 1
t
Thanks for reaching out, mateuszkasprowicz. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about how the On user turn completed hook behaves when there are multiple non-agent participants in a room. Short answer • The hook still fires when a user’s turn ends, but if multiple non-agent participants are present the agent will not automatically separate who’s being tracked unless you configure it to do so. This can make turn boundaries ambiguous when speech overlaps or alternates between participants. What actually happens • The hook receives the same parameters (a
turn_ctx
and the
new_message
) whenever the agent considers a user turn completed. • By default the agent can receive audio from all participants in the room, so the completed-turn event may reflect whichever participant’s audio the agent is currently processing — not necessarily a specific person. • Overlapping or alternating speech from multiple participants can be treated as a single shared input stream, which may produce ambiguous or unexpected turn detection. How to ensure correct behavior (recommended) • Configure the agent to listen to a single participant using
RoomIO
with a fixed
participant
identity. That restricts audio processing and turn detection to that participant so
on_user_turn_completed
corresponds only to that user’s turns. Example (conceptual) 1. Create the AgentSession. 2. Create RoomIO with a
participant
identity you want tracked: ◦ e.g.,
room_io = RoomIO(session, room=ctx.room, participant="specific-participant-identity")
1. Start
room_io
and then start the session/agent. • With this setup,
on_user_turn_completed
is only called for turns from the specified participant. When you might leave it unfiltered • If you want the agent to handle combined input from multiple users (for example, summarizing group audio or detecting any participant speaking), then leave RoomIO unbound to a single participant. Expect that turn boundaries may be less precise. Follow-up questions I can help with • Do you want turn detection tied to one specific participant or do you want the agent to handle group audio? • Which SDK/language are you using so I can show a concrete code example for your setup? If you tell me which behavior you want (per-participant vs. group-level), I’ll provide exact code snippets and next steps. Sources: Pipeline nodes and hooks | LiveKit Documentation | How to set a fixed participant for agent audio processing | examples/frontdesk | livekit/livekit_composite | DeepWiki, with interactive elements