what is the difference between room_finished and s...
# ask-ai
n
what is the difference between room_finished and shutdown_callback handler? Dont both of them essentially mean the same thing?
t
Thanks for reaching out, Hari. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for your question! Let me help clarify the difference between the room_finished event and the shutdown callback handler in LiveKit: • room_finished: This is a server-side webhook event that gets sent when a room ends—specifically after the last participant leaves and the room closes. It’s designed to notify external systems through an HTTP POST to a configured webhook endpoint. This way, you can easily handle tasks like post-processing, analytics, or cleanup on your server side. • Shutdown callback: This works a bit differently. It’s an in-process mechanism used within LiveKit Agents. It triggers when an agent job is about to end, which might happen due to a user action or room disconnection. By registering a callback with
ctx.add_shutdown_callback()
, the agent can gracefully wrap up things like closing connections or freeing resources before the job fully stops. So, to sum it up: room_finished is your external heads-up that a room has completed, while the shutdown callback helps with local cleanup inside the agent. I hope this helps clear things up! If you have any more questions, feel free to ask—we’re here to support you. Sources: Webhooks | LiveKit Docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | livekit-agents/livekit/agents/voice/room_io/room_io.py | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | agents/src/job.ts