steep-shampoo-86436
05/09/2025, 10:06 AMtall-airline-16756
05/09/2025, 10:06 AMtall-airline-16756
05/09/2025, 10:07 AMbulky-telephone-3728
06/12/2025, 1:37 AMtall-airline-16756
06/12/2025, 1:37 AMRoomIO constructor. For example: session = AgentSession(llm=openai.realtime.RealtimeModel())
room_io = RoomIO(session, room=ctx.room, participant="participant-identity")
await room_io.start()
await session.start(agent=MyAgent())
This ensures the agent only processes audio from the specified participant identity.
2. Explicit Agent Dispatch on Participant Connection: You can configure a participant's token to dispatch specific agents when they connect. For example: from livekit.api import (
AccessToken,
RoomAgentDispatch,
RoomConfiguration,
VideoGrants,
)
room_name = "my-room"
agent_name = "test-agent"
def create_token_with_agent_dispatch() -> str:
token = (
AccessToken()
.with_identity("my_participant")
.with_grants(VideoGrants(room_join=True, room=room_name))
.with_room_config(
RoomConfiguration(
agents=[
RoomAgentDispatch(agent_name="test-agent", metadata='{"user_id": "12345"}')
],
),
)
.to_jwt()
)
return token
This approach allows you to dispatch specific agents to handle particular participants.
Let me know if you need further assistance or additional examples!