fierce-jordan-44682
09/18/2025, 9:27 AMtall-airline-16756
09/18/2025, 9:27 AMtall-airline-16756
09/18/2025, 9:27 AMparticipant_disconnected event available in LiveKit SDKs (like Python, JavaScript, Rust) if your backend is directly connected to the room. This is great for handling real-time actions such as bots or agents.
• Webhooks: Another option is to use the participant_left webhook event, which notifies your backend via HTTP whenever a participant leaves. This works perfectly even if your backend isn’t connected to the room.
If you’re letting LiveKit manage room creation for you, no worries—you can still use webhooks without needing to create rooms manually. But if you want to use SDK-based listeners, your backend would need to connect to the room directly.
Please feel free to reach out if you'd like me to walk you through detailed steps for either method. I’m here to help!
Sources: livekit-rtc/livekit/rtc/room.py | stream_audio.py | agent/game_host.py | Handling events | LiveKit Docs | examples/demo/demo.tsfierce-jordan-44682
09/18/2025, 9:28 AMtall-airline-16756
09/18/2025, 9:29 AMparticipant_disconnected, sending messages, or managing participants.
For instance, using the LiveKit SDK, your backend can join the room with an access token, just like any client would. This is especially helpful when your backend needs to actively participate in or keep an eye on the room's activity.
If you'd like, I’d be happy to share more details or examples on how to get this set up—just let me know!fierce-jordan-44682
09/18/2025, 9:31 AMtall-airline-16756
09/18/2025, 9:33 AMAgentSession does handle participant disconnection events, though it does this through its connection with the room. Let me walk you through how it works:
• The AgentSession uses a Room object behind the scenes, which emits a participant_disconnected event whenever someone leaves.
• If you have the close_on_disconnect option enabled (which is the default), the AgentSession will automatically close when the participant it’s interacting with disconnects. You can listen for the close event on the AgentSession to catch this.
• Or, if you want more control, you can listen directly to the participant_disconnected event on the Room object.
If you’d like, I’m happy to share some examples or dive deeper into how to set this up. Just let me know!
Sources: examples/other/transcription/multi-user-transcriber.py | agents/src/voice/events.ts | agent/game_host.py