For manual dispatch via the livekit api, would tha...
# ask-ai
f
For manual dispatch via the livekit api, would that immediately send the agent into the room? or would it wait for someone to join that room first, before the agent joins the room?
t
Thanks for reaching out, Mok. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When you use manual dispatch through the LiveKit API, the agent jumps right into the room as soon as they’re dispatched — even if someone else is already there. And don’t worry, if the room doesn’t exist yet, it’ll be created automatically during the dispatch. Pretty handy, right? Sources: Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | livekit-api/livekit/api/agent_dispatch_service.py | src/main/kotlin/io/livekit/server/AgentDispatchServiceClient.kt | lib/livekit/agent_dispatch_service_client.rb
f
But what if nobody is there for say 10 seconds, does the agent know when to exit the room?
t
Hey there! Just a quick heads-up: LiveKit doesn’t automatically kick an agent out of a room if no one joins within a certain time. But no worries—you can totally add this yourself with a bit of custom logic in the agent’s code: • In the agent’s
entrypoint
function, keep an eye on whether participants show up. • Set a timeout you like (say, 10 seconds) using async tools like
asyncio.wait_for()
around
ctx.wait_for_participant()
. • If no one joins before the timeout, the agent can gracefully disconnect itself with
ctx.shutdown()
. Oh, and there’s also a handy server-side setting called
empty_timeout
that can automatically close rooms with no participants after a certain time, which will disconnect any agents hanging around too. Sources: Voice Assistants | livekit/livekit_composite | DeepWiki | agent-console/components/no-agent-notification.tsx | Web and mobile frontends | LiveKit Docs | livekit-protocol/src/livekit.rs | protobufs/livekit_room.proto