Locally I'm receiving `participant_connected` even...
# agents
n
Locally I'm receiving
participant_connected
event when running with console command. However, when I run via LiveKit Cloud this events are no longer firing when connecting via the LiveKit react-native starter app or my own app. I've spent a lot of time trying to debug with no luck, tried searching through threads but unclear what's different about my implementation. When my agent its noting there are no existing participants logging the bottom of these two lines:
Copy code
if len(room.remote_participants) > 0:
    logger.info("Participants already connected, loading memories now")
    await self._load_memories()
else:
    logger.info("No participants yet, will load memories when participant connects")
Then there's this hook that's registered in my entrypoint:
Copy code
@ctx.room.on("participant_connected")
def on_participant_connected(participant):
    logger.info(f"Participant connected: {participant.identity} (sid: {participant.sid})")
But that's only firing in my local deployment. Finding it difficult to understand if this is an issue with my agent or client code.
r
What version of libraries are you using?
n
Copy code
"livekit-agents[hume]>=1.2.15",
    "livekit-agents[anthropic,elevenlabs,openai,silero,turn-detector]~=1.2",
    "livekit-plugins-noise-cancellation~=0.2",
and clientside:
Copy code
"@livekit/components-react": "^2.9.15",
    "@livekit/react-native": "^2.9.3",
    "@livekit/react-native-expo-plugin": "^1.0.1",
    "@livekit/react-native-webrtc": "^137.0.2",
Anything else that might be helpful?
l
Could this be a lifecycle issue? https://docs.livekit.io/agents/worker/#lifecycle. Running through the
console
has a simplified lifecycle. It depends how your agent is structured and we have examples that show
participant_connected
but if you are using the starter agent, the remote participant should always show as already present in the room after the session has started (so, the connected event would not fire).
r
Ive noticed these issues too, these events are unreliable locally vs production events like
track_subscribed
,
participant_connected
they just don't work all the time across environments sometimes they're not even fired
n
Just got reports that indicate the flakiness @rapid-judge-7554 noted. Some users say the agent is greeting them on entry which is in the code flow for participant_connected events, but others including myself are not able to see this behavior on the same build. One data point I have on the user who noted they experienced the participant_connected code path is they said they had slow internet / bad connection. So possible there was a delay in creating the room and them joining that allowed this to fire. There was no reconnect logic at that time (have since patched), so it wasn't them reconnecting.
👍 1