Thank you for your questions about explicit agent dispatch in LiveKit! I’m happy to help clarify things for you:
1. There’s no built-in restriction stopping a participant from rejoining a room right away with the same token, as long as that token is still valid. Just keep in mind that rejoining might trigger agent dispatch again if your token includes dispatch directives.
2. The cleanup callback could sometimes slow down agent dispatch if it’s doing something that blocks or interferes with the process. To keep things running smoothly, it’s best to make sure this callback is quick and non-blocking.
3. Generally, rejoining with the same token should dispatch the agent right away, assuming the token is valid and there aren’t any blocking operations or bugs in the system. Since LiveKit doesn’t automatically prevent duplicate dispatches, it’s a good idea to add some safeguards on your side—like checking existing dispatches with
listDispatch()
, using short-lived tokens, and managing dispatch state in your backend—to keep everything consistent.
Please feel free to reach out if you’d like me to explain anything further or if you need a hand setting up these safeguards. I’m here to help!
Sources:
Managing participants | LiveKit Docs |
Authentication | LiveKit Docs |
packages/livekit-server-sdk/src/AgentDispatchClient.ts |
Dispatching agents | LiveKit Docs |
Agent dispatch | LiveKit Docs