I am getting this error - ERROR livekit.agents: pr...
# ask-ai
q
I am getting this error - ERROR livekit.agents: process did not exit in time, killing process Is it because the shutdown webhook is taking a lot of time after the call ends?
✅ 1
t
Thanks for reaching out, Harsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about the error message: ERROR livekit.agents: process did not exit in time, killing process Short answer: Yes — a slow shutdown webhook (or any long-running shutdown callback) can cause that error. Why: the agent framework waits a fixed grace period for shutdown tasks (including registered shutdown callbacks and webhooks) to complete. If those tasks don’t finish before the timeout, the agent force-kills the process and logs exactly that message. What you can do next • Confirm whether a shutdown webhook or shutdown callback runs when the call ends. If so, measure how long it takes to complete. • If the webhook sometimes takes longer than the default grace period, you have two options: ◦ Make the webhook faster or move long work off the shutdown path (e.g., enqueue work to a background job or retry queue instead of waiting synchronously). ◦ Increase the shutdown timeout so the process has more time to complete cleanup. How to increase the timeout • Use the
shutdown_process_timeout
parameter in the agent server options to raise the allowed shutdown time. Increasing this value will give shutdown hooks/webhooks more time before the process is killed. If you’d like, tell me: • Whether the webhook is synchronous during shutdown (it waits for a response), and • How long the webhook currently takes (rough estimate). I can then suggest a reasonable timeout value and give a short example of moving the webhook call off the shutdown path if you prefer. Sources: Job lifecycle | LiveKit Documentation | Server startup modes | LiveKit Documentation | Collect recording consent with tasks | LiveKit Documentation, with interactive elements
q
how can I increase shutdown_process_timeout?
t
Thanks — I’m following up on your question about increasing
shutdown_process_timeout
. I can show the exact change, but first a quick clarifying question: are you using a LiveKit agent running with the agent server options in code (for example, starting agents programmatically in Python/Go), or are you deploying via a configuration file / container where you pass options as environment variables or flags? That will determine the exact place to set
shutdown_process_timeout
. If you tell me which language or deployment method you’re using (Python, Go, Docker container, Kubernetes, etc.), I’ll provide the precise example and a recommended new value. , with interactive elements
q
I am using python SDK
t
Thanks — I’m responding to your question about how to increase
shutdown_process_timeout
when using the Python SDK. You can set
shutdown_process_timeout
when constructing the
AgentServer
. It’s the number of seconds the agent will wait for shutdown callbacks (including webhooks) to finish before forcefully killing the process. The default is 10 seconds. Example (Python):
Copy code
from livekit import AgentServer
from livekit.cli import cli

server = AgentServer(
    shutdown_process_timeout=30  # increase to 30 seconds (adjust as needed)
)

if __name__ == "__main__":
    cli.run_app(server)
Recommendations • If your shutdown webhook sometimes takes longer than 10s, try 30s–60s to start, then lower if you optimize the webhook. • Prefer making webhooks asynchronous during shutdown (enqueue background work) so shutdown completes quickly and long tasks don’t delay process exit. • Measure typical webhook runtime and set the timeout slightly above that to avoid unnecessary forced kills. If you want, tell me: • the current webhook runtime (approx), and • whether the webhook call is synchronous during shutdown. I can suggest a concrete timeout value and an example pattern to offload webhook work if you’d like. Sources: Job lifecycle | LiveKit Documentation | Pi Zero Transcriber | LiveKit Documentation, with interactive elements