when session closes. it takes some time to execute...
# ask-ai
l
when session closes. it takes some time to execute the shutdown_callbacaks how to reduce it
✅ 1
t
Thanks for reaching out, Rajadurai. 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 shutdown callbacks taking too long after a session closes. Short answers you can try now: • The agent waits 10 seconds by default for shutdown callbacks. You can reduce that by setting
shutdown_process_timeout
in agent server options to a smaller value. • Optimize your callback work: make I/O/database calls faster, batch writes, or reduce synchronous work. • Offload non‑critical work to an async background job or queue so the shutdown path only does essential cleanup. Quick checklist to follow: 1. Confirm your current
shutdown_process_timeout
and lower it if appropriate. 2. Profile the callback to find slow operations (DB, HTTP calls, file I/O). 3. Move long-running tasks to a background worker or retryable job queue. 4. Ensure you’re not unintentionally blocking on retries or heavy synchronous processing during shutdown. 5. If observability uploads run at shutdown, make them async or perform them outside the critical shutdown path. If you want, tell me: • which agent/SDK you’re using and where your callbacks perform I/O (DB, HTTP, files), and I’ll suggest concrete optimization or code patterns. Sources: Job lifecycle | LiveKit Documentation | Why is my Agent insights data missing? | LiveKit | Deployment reliability on LiveKit Cloud | LiveKit, with interactive elements