happy-night-10979
06/25/2025, 10:16 AMtall-airline-16756
06/25/2025, 10:16 AMtall-airline-16756
06/25/2025, 10:16 AMdeleteRoom
method to end the session for all participants and remove the room from the server. Here's an example: `from livekit import api
async def entrypoint(ctx: JobContext):
api_client = api.LiveKitAPI(
os.getenv("LIVEKIT_URL"),
os.getenv("LIVEKIT_API_KEY"),
os.getenv("LIVEKIT_API_SECRET"),
)
await api_client.room.delete_room(api.DeleteRoomRequest(
room=ctx.job.room.name,
))`This will send a "Disconnected" room event to all participants and delete the room.
2. Disconnecting the agent only: If you only want to disconnect the agent while keeping the room active for other participants, you can use the ctx.shutdown()
method: async def entrypoint(ctx: JobContext):
# Disconnect from the room
ctx.shutdown(reason="Session ended")
Using the first approach ensures the room is deleted, allowing a new conversation to start with a fresh room and agent dispatch.
Sources: Inside a session | LiveKit Docshappy-night-10979
06/25/2025, 10:31 AMtall-airline-16756
06/25/2025, 10:31 AMdeleteRoom
API in LiveKit, the room gets zapped from the server's memory right away. Any participants in the room will be automatically disconnected with a "ROOM_DELETED" heads-up.
I totally get that it can be frustrating if you're seeing delays with agent dispatching after creating a new room. This might be happening because of some behind-the-scenes processing. No worries, though! You might want to double-check that the room deletion is completely done before spinning up a new one, or maybe add a tiny pause between actions to give the system a chance to catch its breath.
Sources: Connecting to LiveKit | LiveKit Docs | GitHub::livekit::livekit_composite | livekit/livekit-cli/cmd/lk/room.go