fierce-jordan-44682
09/27/2025, 5:38 AMtall-airline-16756
09/27/2025, 5:38 AMtall-airline-16756
09/27/2025, 5:39 AMdrain_timeout parameter in LiveKit, which helps manage how an Agent Worker handles active jobs when it's time to shut down gracefully. When the worker gets a shutdown signal, it stops taking on new jobs but gives the current tasks some time to finish up within this timeout period.
For instance, if an agent session is busy processing audio or saving its state, it will keep working on these until they're done or until the drain_timeout limit is reached. By default, this timeout is set to 30 minutes (1800 seconds). If the tasks aren’t wrapped up by then, they might be stopped forcefully.
This approach helps make sure sessions close out properly, so you don’t have to worry about losing data or having incomplete responses during shutdown. I hope this clarifies how it works, and please feel free to ask if you have any more questions!
Sources: Docs::Agents | Worker options | LiveKit Docs | livekit-agents/livekit/agents/utils/connection_pool.py | Inside a session | LiveKit Docs