orange-fireman-69650
11/25/2025, 4:59 PMtall-airline-16756
11/25/2025, 4:59 PMtall-airline-16756
11/25/2025, 5:00 PMwrite_transcript to run during post-shutdown cleanup (to save transcripts/logs).
• Runs after the session or room has already ended.
How to find the actual reason the call ended:
• Check server logs for events like delete_room, participant_removed, or other ROOM_DELETED events.
• Search your code for explicit shutdown calls such as session.shutdown() or room.disconnect().
• If you use session reports (Python agents), view the session report metadata — it includes session end reasons.
If you want, tell me:
• which agent/service logs you can access (server logs or session reports),
• the timestamp or session/room ID for the call,
and I’ll suggest the exact log entries or commands to look for.
Sources: Job lifecycle | LiveKit docs | Observability data hooks | LiveKit docs | Connecting to LiveKit | LiveKit docsorange-fireman-69650
11/25/2025, 5:01 PMtall-airline-16756
11/25/2025, 5:02 PMwrite_transcript. Good idea — you can record the end reason and save it with your transcript.
What to do (Python agent):
1. Listen for the session close event and read its `error`:
@session.on("close")
def on_close(event):
reason = None
if event.error:
# contains exception info and `recoverable` flag
reason = f"error: {event.error}, recoverable: {event.error.recoverable}"
else:
reason = "ended gracefully"
# save reason somewhere (file, DB) or attach to transcript
1. In your shutdown callback, include that reason when writing the transcript:
async def write_transcript():
report = ctx.make_session_report() # structured session metadata (Python)
# combine transcript + report or reason and write to file
ctx.add_shutdown_callback(write_transcript)
Additional useful signals:
• For SIP calls, check sip.callStatus on the participant (e.g., hangup vs active).
• LiveKit Cloud/dashboard and server logs show disconnect reasons like STATE_MISMATCH, PEER_CONNECTION_DISCONNECT, or ROOM_DELETED — correlate those with your session ID and timestamps.
If you want, tell me which environment you run (Python agent, SIP, or LiveKit Cloud) and a sample session or room ID and I’ll give the exact code/log entries to capture and save the end reason with your transcript.
Sources: Events and error handling | LiveKit docs | Observability data hooks | LiveKit docs | SIP participant | LiveKit docs | Understanding the STATE_MISMATCH Disconnect Reason | Connecting to LiveKit | LiveKit docs