for inbound calls, how can the agent exit a room s...
# ask-ai
s
for inbound calls, how can the agent exit a room such that the livekit server doesnt dispatch another agent to the same room ?
✅ 1
t
Thanks for reaching out, Sameer. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're asking how an agent should leave an inbound call room so the LiveKit server does not dispatch another agent to that same room. Two reliable ways to prevent re-dispatch: • Use RoomOptions to delete the room when the session ends: set
delete_room_on_close = True
for the session. That causes the room to be deleted when the agent leaves, so no further dispatch will target it. • Or explicitly delete the room via the server API (for example, call
deleteRoom
) after the agent exits. Deleting the room disconnects remaining participants and prevents further dispatch to that room. Also review your dispatch rules to ensure only a single agent is intended per session (explicit dispatch or one‑agent rules) so automatic dispatch won’t send replacements. Which method do you prefer or are you using a specific SDK/language so I can give exact code/snippet? Sources: Server lifecycle | LiveKit Documentation | https://docs.livekit.io/agents/logic/sessions.md| | Agent session | LiveKit Documentation | Job lifecycle | LiveKit Documentation | Agent dispatch | LiveKit Documentation, with interactive elements
s
2 participants are having a conversation so the room shouldn't be deleted. the agent is no longer required in the room
t
Thanks — I’m responding to your follow-up: you want the agent to leave while two participants keep talking, and you don’t want LiveKit to dispatch another agent. Do this: • Ensure the room uses explicit dispatch (set
agent_name
when assigning the agent). If an agent is explicitly dispatched, LiveKit will not auto-reassign another agent when that agent disconnects. • Do not set
delete_room_on_close = True
. That would delete the room when the agent session ends. • Have the agent perform a graceful disconnect (e.g.,
session.shutdown()
or
ctx.shutdown()
/ disconnect API). This removes the agent but leaves the room active for remaining participants. If you’d like, tell me which SDK/language you’re using (Node, Python, Go, etc.) and I’ll provide the exact snippet to call for a clean exit. Sources: Agent dispatch | LiveKit Documentation | Job lifecycle | LiveKit Documentation | Server lifecycle | LiveKit Documentation, with interactive elements