Hi LiveKit Team,
I need to detect the exact reason why a room ended so I can handle each case differently on my backend. Specifically I need to distinguish between the following scenarios:
-
User ended the call — user clicked the end call button and the frontend called
room.disconnect() -
AI ended the interview — the agent called
room.disconnect()from the Python server via a tool function -
User lost internet connection — user disconnected due to network issues
-
User closed the browser tab or page — without explicitly clicking end call
-
System or agent error — any other unexpected failure such as LLM, TTS, STT, agent crash, stream failure, socket error, or token expiry
Could you help me understand:
- Is there a way to detect and differentiate between all of the above reasons when a room ends?
- What is the recommended approach to handle and log each of these cases separately?