I have an agent server running locally towards LK cloud. If I join a room with this below token, the agent is dispatched.
lk token create
–api-key …
–api-secret …
–room test-room7
–join
–identity Umut
–agent victor-seer
–job-metadata ‘{“linked_participant_identity”:“Umut”}’ \
If I create another token, the same way, for another identity, the agent doesn’t get dispatched this time when the second identity joins. In a similar way, if I join a participant to a room (without linked agent token) then later if I join a second participant (with linked agent token) the agent is not dispatched either when the second participant joins.
It is almost like the agent dispatch can only happen on the first participant.
The agent logs don’t indicate anything because the job doesn’t even reach the agent server.
Am I missing something?
Are you having multiple agents and multiple participants join the same room at different times?
I would only expect the second user to trigger an agent to join if the original agent has left the room, and even then I haven’t tried it
.
It was designed with the use case where a participant joins a unique room and has a conversation with a single agent. If multiple participants need to speak with an agent in the same room, the agent should stay in the room.
If multiple participants need to speak with multiple agents separately, you would use a unique room ID
If multiple participants need to speak with multiple agents simultaneously, you need to explicitly dispatch those agents, https://docs.livekit.io/agents/server/agent-dispatch/#explicit
It looks like your use case is for multiple participants to speak with multiple agents in a long running room - that I am less sure about, but I would recommend using unique rooms for each interaction if that is possible.
Thank you for your reply.
To clarify, I am not using AgentSession and my programatic participant is not a voice agent. It looks at newly joined participants video. 1 agent instance per 1 participant.
When the agent dispatch job is accepted (handle_request), I assign a unique participant identity and accept the request. The unique identity joins the room and looks at video for a while and exits.
This all works if I explicit dispatch a job (lk dispatch create). Things don’t work if I link the participant token to an agent (lk token create --join --identity --agent) instead of manual dispatch.
I have this simple test, if you could also verify.
- Create a token with lk token create --join --identity A and join to room X.
- Start your agent server
- Create a token with lk token create --join --identity B --agent and join to room X.
The agent dispatch job never reaches the agent server, therefore agent never starts.
Hi @darryncampbell . Any thoughts?
You need to use explicit dispatch for that second agent in same room
You are confirming that only the first participant can dispatch agent job with participant token. For other participants explicit dispatch is needed. Correct?
Is this documented behavior?
Where should I open I change request? It would simplify our side if we don’t need to control the explicit dispatch.
The docs for ‘Agent dispatch in tokens’, Custom token generation | LiveKit Documentation , clarify that “For 1:1 agent applications…” which is referring to having 1 participant and 1 agent in a single room. You could technically interpret it as the ratio of agents to participants should be 1:1, which is your use case, but that isn’t the intent behind the sentence as your use case is uncommon 
For your use case, as CWilson says, you would need to use explicit dispatch.
Where should I open I change request? It would simplify our side if we don’t need to control the explicit dispatch.
It feels like that would be a very large change, so I think an enhancement request would be unlikely to be taken up (though I’m not familiar with the code base). The code is all open source at GitHub - livekit/livekit: End-to-end realtime stack for connecting humans and AI · GitHub