how to get remote participant in a room using pyth...
# ask-ai
l
how to get remote participant in a room using python
t
Thanks for reaching out, Rajadurai. 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 to get remote participants in a room using Python. You can read remote participants from the Room object’s
remote_participants
dictionary. That dictionary maps participant identities to
RemoteParticipant
objects, and you can iterate its values to access each participant’s properties (like
identity
and
state
). Example usage:
Copy code
# Example: Accessing remote participants in an RTC session
@server.rtc_session(agent_name="my-agent")
async def entrypoint(ctx: JobContext):
    # Connect to the room
    await ctx.connect()

    # Iterate all remote participants
    for participant in ctx.room.remote_participants.values():
        print(f"Participant identity: {participant.identity}")
        print(f"Participant state: {participant.state}")
If you need to know which specific participant the agent is linked to after the session starts, use the linked participant reference:
Copy code
# After session.start()
linked_participant = session.room_io.linked_participant
print(f"Linked participant: {linked_participant.identity}")
Notes and tips • Remote participants appear in
remote_participants
once they join the room. • You can attach event listeners (for example
participant_connected
) to react when participants join or leave. • The first remote participant to join is commonly treated as the default linked participant unless you change that with
RoomOptions
. If you’d like, tell me: • Are you working inside an agent session or a plain RTC client? • Do you need an example that reacts to participants joining/leaving (event handlers) or one that inspects participants at a single point in time? I can follow up with the exact code you need based on your setup. Sources: client-sdk-js | livekit/livekit_composite | DeepWiki | Agent session | LiveKit Documentation | Job lifecycle | LiveKit Documentation