when optimistically dispatching agents at token cr...
# ask-ai
r
when optimistically dispatching agents at token creation, how would it work concurrently so that its separated? if my agent identity is abc123 and i dispatch it at token creation and then other user also starts a room with that abc123, is that the correct approach to have two rooms at the same time with the different agent entities?
t
Thanks for reaching out, Prince. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When optimistically dispatching agents at token creation, LiveKit allows for explicit agent dispatch to ensure proper separation and concurrent handling of rooms. Here's how it works: • Each agent can be identified using the
agent_name
field in the
WorkerOptions
. • You can use the
AgentDispatchService
to explicitly dispatch the agent to a specific room. • Alternatively, you can configure a participant's token to dispatch one or more agents upon connection using
RoomAgentDispatch
entries in the
RoomConfiguration
. This approach ensures that even if two users start rooms with the same agent identity (e.g., "abc123"), the agents are handled separately and can operate concurrently in different rooms. This method is particularly useful for scenarios like SIP inbound calls where explicit agent dispatch is recommended over automatic dispatch. If you have further questions or need assistance implementing this, feel free to ask! Sources: Web and mobile frontends | LiveKit Docs | Agent dispatch | LiveKit Docs