able-jackal-19719
10/28/2025, 11:09 PMself.session.shutdown() for?tall-airline-16756
10/28/2025, 11:09 PMtall-airline-16756
10/28/2025, 11:09 PMself.session.shutdown() method is a helpful way to gracefully disconnect an agent from a room once its task is done. It makes sure that any ongoing activities, like active audio or message streams, are fully completed before the agent disconnects, which helps prevent any data from being lost.
By default, it patiently waits for up to 60 seconds for any registered shutdown hooks to finish their work, but you can always customize this timeout to better fit your needs. It also takes care of the final cleanup steps, like closing WebSocket connections and releasing media resources, in an efficient, asynchronous way.
Sources: Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | livekit-agents/livekit/agents/ipc/job_proc_lazy_main.py | Job lifecycle | LiveKit Docsable-jackal-19719
10/28/2025, 11:10 PMtall-airline-16756
10/28/2025, 11:11 PMshutdown_process_timeout parameter within the WorkerOptions class. This setting determines how long the framework will wait for all shutdown hooks to finish before it forcefully ends the process. By default, it’s set to 60 seconds, but feel free to adjust it to whatever works best for your needs.
Here’s a friendly example in Python to guide you:
from livekit.agents import WorkerOptions, cli
opts = WorkerOptions(
entrypoint_fnc=your_entrypoint_function,
shutdown_process_timeout=120.0 # Set to 2 minutes (default is 60 seconds)
)
cli.run_app(opts)
If you have any questions or need a hand with this setup, just let me know—I’m here to help!
Sources: Job lifecycle | LiveKit Docs | examples/voice_agents/inactive_user.py | Worker options | LiveKit Docs