clever-apartment-50437
10/08/2025, 9:30 PMtall-airline-16756
10/08/2025, 9:30 PMtall-airline-16756
10/08/2025, 9:30 PMctx.room.remote_participants is actually a dictionary, not a list, so using [0] to index it won’t work. No worries though! Here are a couple of ways to fix this:
• You can convert the dictionary values to a list and then check if there are any participants before trying to access the first one:
remote_participants = list(ctx.room.remote_participants.values())
if not remote_participants:
logger.info("No remote participants found")
return
participant = remote_participants[0] # Safe to access
• Or, you might prefer using next(iter(...)) to grab the first participant, just making sure the dictionary isn’t empty first.
Also, if you’re working with audio from a specific participant, it might help to set a fixed participant when you start the agent session. That way, you won’t have to depend on the order inside the dictionary. I hope this helps! Feel free to ask if you want me to walk you through any of these steps. Sources: livekit-rtc/livekit/rtc/room.py | complex-agents/teleprompter/cartesia-ink.py | How to set a fixed participant for agent audio processing