big-controller-60015
09/05/2025, 6:45 AMtall-airline-16756
09/05/2025, 6:45 AMtall-airline-16756
09/05/2025, 6:46 AMparticipantDisconnected event and see if disconnectReason === CLIENT_INITIATED. This means the user chose to disconnect.
• Agent-Side: Watch for the close event on the AgentSession. If reason === PARTICIPANT_DISCONNECTED, it shows the user disconnected the agent.
If you'd like, I’m happy to share more details or examples to help you out!
Sources: livekit-rtc/livekit/rtc/_proto/participant_pb2.pyi | AI voice agents | LiveKit Docs | web/src/components/chat.tsx | web/src/components/chat.tsx | complex-agents/shopify-voice-shopper/shopify-voice-frontend/app/page.tsxbig-controller-60015
09/05/2025, 7:04 AMtall-airline-16756
09/05/2025, 7:05 AMparticipantDisconnected event listener is set up correctly in your agent implementation.
2. Double-check that your event handler is actually logging the disconnectReason field. For Python, that’s participant.disconnect_reason, and for JavaScript, it’s participant.disconnectReason.
3. Take a look at your agent configuration and confirm the closeOnDisconnect option is turned on so logs get triggered when someone disconnects.
4. Lastly, verify your LiveKit server version supports the disconnect_reason field within ParticipantInfo.
If you’re still running into trouble after these steps, just give me a shout—I’m here to help you dig a little deeper!
Sources: protobufs/livekit_models.proto | livekit-agents/livekit/agents/voice/room_io/room_io.py | agents/src/voice/room_io/room_io.tsbig-controller-60015
09/05/2025, 7:13 AMtall-airline-16756
09/05/2025, 7:14 AMparticipantDisconnected event in your agent's setup.
2. Grab the disconnectReason from the participant object. Here’s how it looks:
JavaScript Example:
room.on(RoomEvent.ParticipantDisconnected, (participant) => {
console.log('Disconnect reason:', participant.disconnectReason);
});
Python Example:
@session.on("close")
def on_close(ev: CloseEvent):
print("Disconnect reason:", rtc.DisconnectReason.Name(ev.reason))
If you hit any bumps or want a hand with implementation or debugging, just give me a shout—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/room_io/room_io.py | livekit-ffi/src/livekit.proto.rs | packages/livekit-rtc/src/proto/participant_pb.ts | agent-console/lib/event-definitions.tsx | protobufs/livekit_models.protobig-controller-60015
09/05/2025, 8:51 AMtall-airline-16756
09/05/2025, 8:52 AMparticipant_disconnected event in LiveKit agents. This event has a handy disconnect_reason field that tells you exactly why the disconnection happened.
Python Example:
@room.on("participant_disconnected")
def on_participant_disconnected(participant: rtc.Participant):
logging.info(f"Participant {participant.identity} disconnected, reason: {rtc.DisconnectReason.Name(participant.disconnect_reason)}")
If you want, I’m here to help with more examples or to walk you through it in other programming languages—just let me know!
Sources: livekit-rtc/livekit/rtc/_proto/participant_pb2.pyi | agent-console/lib/event-types.ts | livekit-agents/livekit/agents/voice/room_io/room_io.py | Runtime/Scripts/Proto/Participant.cs | livekit/livekit_models.pb.go