Can you explain drain_timeout? <https://docs.livek...
# ask-ai
f
Can you explain drain_timeout? https://docs.livekit.io/agents/worker/options/#log-levels Does that mean that if I try to stop the agent session, it will still continue up until the drain timeout??
t
Thanks for reaching out, Mok. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd like to explain a bit about the
drain_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