proud-lawyer-39815
12/17/2025, 3:33 PMtall-airline-16756
12/17/2025, 3:33 PMtall-airline-16756
12/17/2025, 3:33 PMparticipant_disconnected. Do you mean one of these?
• The server/host process shutting down after a room becomes empty.
• The LiveKit Room/Client SDK automatically disconnecting a client after the app exits (the 15-second behavior).
• A custom application process you run when you receive the ParticipantDisconnected event.
Tell me which one you mean (or describe your exact setup), and I’ll give the precise behavior and what you can control.
Sources: Connecting to LiveKit | LiveKit docs | Rooms, participants, and tracks | LiveKit docsproud-lawyer-39815
12/17/2025, 3:33 PMtall-airline-16756
12/17/2025, 3:34 PMempty_timeout period when no participants remain. The default empty_timeout is 20 seconds (this is configurable when creating rooms or in self-hosted settings). The server process itself continues running and will accept new rooms or connections unless you explicitly stop it.
Sources: Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Managing rooms | LiveKit docs | Job lifecycle | LiveKit docsproud-lawyer-39815
12/17/2025, 3:42 PMself._call_sip_ctx.room.on(
"participant_disconnected",
lambda: asyncio.create_task(self._shutdown()),
)
If _shutdown takes longer than 5 seconds to execute, what happens? Does livekit shutds down the job?tall-airline-16756
12/17/2025, 3:42 PM_shutdown with asyncio.create_task() on participant_disconnected. That task runs independently — LiveKit/Agents does not kill it after 5 seconds.
What happens:
• The task will continue running until it completes or the agent process is terminated.
• The Agents framework waits for shutdown hooks but will forcefully terminate the process only after the configured shutdown_process_timeout (default 60 seconds).
• If your _shutdown finishes within shutdown_process_timeout, it will complete normally. If it exceeds that timeout, the process may be forcefully terminated.
If you want, I can show how to:
• increase shutdown_process_timeout, or
• make _shutdown async with a cancellable pattern and a short internal timeout. Sources: Job lifecycle | LiveKit docsproud-lawyer-39815
12/17/2025, 3:43 PMtall-airline-16756
12/17/2025, 3:43 PMshutdown_process_timeout is applied.
• It's used when the Agents framework initiates a graceful shutdown of the agent process — for example when all participants have left a room and the agent begins its shutdown sequence, or when the server/process is explicitly stopped.
• At that point the framework waits for registered shutdown hooks (like your _shutdown task) to finish.
• The shutdown_process_timeout value (default 60 seconds) is the maximum time the framework will wait for those hooks; if hooks haven't completed by then, the process may be forcefully terminated.
Would you like the exact place to configure shutdown_process_timeout or an example of a cancellable _shutdown pattern?proud-lawyer-39815
12/17/2025, 3:44 PMtall-airline-16756
12/17/2025, 3:44 PMshutdown_process_timeout in your agent/server config, or
• provide a cancellable async _shutdown pattern with a short internal timeout to avoid hitting the process-level timeout.
Which would you prefer?proud-lawyer-39815
12/17/2025, 4:24 PMprocess exiting, so it isn't necessarily a timeouttall-airline-16756
12/17/2025, 4:24 PMSIGTERM or SIGINT, or messages containing draining, shutdown, disconnect, or session ended?
• Is your code calling process.exit(), sys.exit(), room.disconnect(), session.shutdown(), or similar after participant_disconnected?
• Do you have agent server options set for drain_timeout or shutdown_process_timeout (values)?
What to look for in logs (share lines if possible):
• Receipt of `SIGTERM`/`SIGINT` or "draining" — indicates external shutdown signal or orchestrator.
• Messages about session ended or all participants left followed by explicit exit calls — indicates application-level exit.
• Container runtime messages like Killed or OOM — indicates resource kills.
• Any stack trace or explicit process exiting caller name.
What I can do once you share logs/config:
• Point to whether the exit is from agent shutdown hooks (and whether shutdown_process_timeout would apply).
• Identify if an orchestration/system signal likely triggered the exit.
• Suggest the exact config change or code pattern to avoid premature exit (increase timeouts, make _shutdown cancellable, or prevent process.exit calls).
Which logs/config can you share first?
Sources: Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Job lifecycle | LiveKit docs | Agent server options | LiveKit docsproud-lawyer-39815
12/17/2025, 4:27 PMtall-airline-16756
12/17/2025, 4:27 PMshutdown_process_timeout (default 60s) is how long the framework waits for those hooks (like your _shutdown) before forcefully terminating the process.
• The room empty/agent-session behavior is automatic; the server process itself (the LiveKit server) isn't killed by this — it's the agent/session process lifecycle that ends.
You can change behavior by adjusting agent server options:
• Increase shutdown_process_timeout to allow longer shutdown hooks.
• Disable/alter automatic session shutdown (keep-alive or auto-shutdown settings) if you want the agent to remain after participants leave.
If you want, paste your agent config or the log lines around "process exiting" and I’ll point to the exact option to change and an example config snippet.