jolly-eve-3916
08/04/2025, 7:32 PMtall-airline-16756
08/04/2025, 7:32 PMtall-airline-16756
08/04/2025, 7:33 PMagentName in WorkerOptions. You can also check server logs for the CreateDispatch RPC call to confirm that the dispatch is being created.
2. Agent State Requirements: The agent must be registered with a specific agentName for dispatch to work. There is no explicit requirement for the agent to be in a specific state like "ready" beyond being registered.
3. Handling Incorrect Room Assignments: If an agent calls ctx.shutdown() after receiving the wrong room type, the room will disconnect, and the job will terminate. LiveKit does not automatically retry with another agent, so you would need to implement retry logic in your application.
4. Ensuring Specific Agents Handle Specific Room Types: Use explicit agent dispatch to assign agents to specific rooms. Assign unique agentName values to your agents and use the createDispatch method to target specific agents. Additionally, you can pass metadata during dispatch to provide context about the room type.
Let me know if you need further assistance with implementing these solutions!
Sources: packages/livekit-server-sdk/src/AgentDispatchClient.ts | livekit/livekit_agent_dispatch.pb.go | Agent dispatch | LiveKit Docs | Dispatching agents | LiveKit Docs | Dispatching agents | LiveKit Docsjolly-eve-3916
08/04/2025, 7:37 PMtall-airline-16756
08/04/2025, 7:39 PMagentName, since that’s key for explicit dispatch to work smoothly.
2. Do agents need different ws_url or other configurations? Nope, all agents can connect using the same LiveKit Cloud URL. There’s no need for different ws_url values between agents.
3. Is there a race condition or timing issue? Agents should be registered with their agentName before dispatching happens. LiveKit has safeguards to help avoid race conditions, but it’s best to ensure your agents are fully initialized and registered before creating dispatches.
4. Default agent behavior: If an agent starts without an agentName, it will automatically get all non-dispatched rooms. If you explicitly set an agentName, this automatic behavior is turned off.
5. Debugging dispatch routing: You can use the LiveKit CLI or SDK to check active dispatches. For example, running lk dispatch list <room_name> shows all active dispatches, or you can use the listDispatch method in the SDK to get dispatch details programmatically.
About your workaround plan—if an agent calls ctx.shutdown() after getting the wrong room type, the room will disconnect and the job will end. LiveKit doesn’t automatically retry with another agent, so you’d want to add retry logic in your app to handle that.
Feel free to reach out if you want to chat more or need any other help!
Sources: examples/agent-dispatch/index.ts | Cloud Architecture | LiveKit Docs | delay-handling/raw_data.txt | pkg/service/agentservice.go | Dispatching agents | LiveKit Docsjolly-eve-3916
08/04/2025, 7:39 PMDispatch created:,
dispatch); // This logs successfully
3. ❌ BUT: cora-voice-agent still receives
all rooms (both PTT and voice)
Critical Questions:
1. Agent Registration Timing: Our agents
are deployed as separate ECS tasks. Could
there be a timing issue where
createDispatch is called before the PTT
agent registers? How can we verify an
agent is registered and ready?
2. Multiple Agents Same Process vs
Separate: We run agents as separate
processes/containers. Does dispatch only
work if agents are in the same process
with different names?
3. Default Agent Behavior: Is there a
concept of a "default" agent? We notice
cora-voice-agent always gets rooms even
when we explicitly dispatch to
cora-ptt-agent.
4. Debugging Tools:
- How can we list all registered agents?
- How can we verify a dispatch is active
for a room?
- Are there LiveKit Cloud logs we can
access to see dispatch routing decisions?
5. Alternative Approach: Since
ctx.shutdown() doesn't trigger retry,
what's the recommended pattern for having
multiple agents where each handles
different room types? Should we:
- Use a single agent with mode
switching?
- Implement a dispatcher agent that
delegates?
- Something else?
We're on LiveKit Cloud (not self-hosted)
if that affects dispatch behavior.
Thank you for your help - we're stuck
without being able to route to different
agents!