bored-father-15295
09/22/2025, 1:44 AMtall-airline-16756
09/22/2025, 1:45 AMtall-airline-16756
09/22/2025, 1:45 AMdelete_room API to close the session for all participants. This way, no one will remain in the room. Just a quick tip: before calling this, use ctx.wait_for_playout() to let the agent finish speaking smoothly.
• Disconnect Only the Agent: If you'd prefer the agent to leave but keep the other participants connected, simply use ctx.shutdown(). This will disconnect the agent while the session stays active for everyone else.
Please feel free to reach out if you'd like more details or need any help with the implementation. I'm here to support you!
Sources: Inside a session | LiveKit Docs | Agent speech and audio | LiveKit Docs | basics/exit_message.py | Agents telephony integration | LiveKit Docs | Job lifecycle | LiveKit Docsbored-father-15295
09/22/2025, 1:57 AMtall-airline-16756
09/22/2025, 1:58 AMdisconnected event on ctx.room. This event includes a reason field, such as ROOM_CLOSED (when all participants have left) or ROOM_DELETED (when the room has been explicitly deleted).
• Use Shutdown Callbacks: Another approach is to register a shutdown callback using ctx.add_shutdown_callback(). This callback is triggered when the room closes, and you can check the reason parameter to understand why.
• Programmatically Close the Room: If you decide to close the room using the deleteRoom API, please note that all participants, including the agent, will be disconnected with a ROOM_DELETED reason.
If you'd like, I’m here to provide more details or examples to make this easier for you. Just let me know!
Sources: Job lifecycle | LiveKit Docs | pkg/agent/worker.go | Inside a session | LiveKit Docs | protobufs/rpc/agent.proto | Connecting to LiveKit | LiveKit Docs