nutritious-businessperson-79241
03/15/2026, 12:50 PMtall-airline-16756
03/15/2026, 12:50 PMtall-airline-16756
03/15/2026, 12:50 PMagent_name will be auto-dispatched to new rooms. Remove agent_name from your @server.rtc_session() if you want automatic dispatch.
◦ Explicit dispatch: if you set agent_name in your agent code, you must dispatch that named agent (via CLI/API or embed dispatch in the participant token). Ensure the agent_name used in dispatch matches exactly the agent_name declared by your agent.
1. Mismatch between agent name in code and dispatch
◦ Check your agent declaration (example decorator/registration) and the dispatch rule—they must match.
1. Network/firewall or routing issues
◦ Ensure the agent host can reach your self-hosted LiveKit server (WebSocket/TCP ports, TLS). Verify DNS and ports from the agent machine.
1. Room created without dispatch rule (when using explicit dispatch)
◦ If using explicit dispatch, create a dispatch rule for the room. You can also include dispatch rules when creating participant tokens (not to be confused with giving an agent a participant token).
Quick troubleshooting steps
1. Start or restart your agent server and watch logs.
2. Create a new test room with automatic dispatch (remove agent_name) to confirm the agent auto-joins.
3. If you must use named agents:
a. Ensure agent declares agent_name in code.
b. Dispatch the agent for that room (CLI/API/embedded dispatch).
1. Verify connectivity between agent host and LiveKit server (ping, curl to LIVEKIT_URL, check ports).
2. Check agent logs for dispatch/connection errors and share any error lines if you want me to help interpret them.
If you share:
• Whether your agent uses automatic or explicit dispatch,
• The agent_name if set, and
• Any relevant agent log errors or the agent’s connection output,
I can give targeted next steps to get the agent into the room.
Sources: Agent dispatch | LiveKit Documentation | Build a salary negotiation coach with a LemonSlice avatar | LiveKit | Simple Call Answering Agent | LiveKit Documentation | Introduction | LiveKit Documentationnutritious-businessperson-79241
03/15/2026, 1:03 PMtall-airline-16756
03/15/2026, 1:03 PMagent_name. The agent runs and waits; when a room is created, LiveKit tells it to join.
• How to test: Remove agent_name from your agent declaration and create a new room. If the agent server is running and reachable, it should auto-join.
2) Explicit dispatch
• What it is: You give an agent a specific name (for example, "voice-bot-v1"), then explicitly tell LiveKit to dispatch that named agent to a specific room. Only when that explicit dispatch occurs will that agent connect.
• When to use: Useful when you have multiple agent types and want only certain agents in certain rooms.
• How it looks in code: Your agent registers with agent_name="voice-bot-v1" (or similar). You then create a dispatch via CLI/API or include dispatch rules when creating a participant token for a room to request that named agent.
• How to test: Ensure the agent_name in your agent code exactly matches the name you dispatch. Then run the dispatch command or API call to send the agent to the room.
Why tokens don’t replace dispatch
• Participant/JWT tokens authenticate clients to join a room. They do not instruct an agent process to connect.
• Agents are connected by the server’s dispatch system, not by receiving a participant token.
Simple examples
• Automatic dispatch example:
◦ Agent code: registers with no agent_name.
◦ Action: Create a room. LiveKit tells the running agent process to join that room automatically.
• Explicit dispatch example:
◦ Agent code: registers as agent_name="my-agent".
◦ Action: Run a dispatch command (or call the API) saying “dispatch my-agent to room test-room.” LiveKit instructs that named agent process to connect to test-room.
What to check next
• Is your agent code registering with an agent_name? If yes, you’re in explicit dispatch mode and must dispatch that name.
• Is your agent process running and connected to LiveKit? If it’s not running, neither automatic nor explicit dispatch will reach it.
• Check agent logs for dispatch-related messages (attempts to connect, rejected dispatch, etc.).
If you share:
• the agent registration snippet (the line where you register the agent or decorator with agent_name, if present), and
• any short log lines showing agent startup,
I’ll point out whether you’re set up for automatic or explicit dispatch and give the exact command or code to dispatch the agent.nutritious-businessperson-79241
03/15/2026, 1:09 PMtall-airline-16756
03/15/2026, 1:09 PMcli.run_app(...).
◦ Check the agent logs to confirm it connected and registered its agent_name.
1. Dispatch the named agent to a room
◦ Use the CLI or API to dispatch "VoiceAssistantAgent" to the target room. For example (CLI-style):
i. Create or identify the room name (e.g., my-room).
ii. Run a dispatch create command specifying the room and `agent_name`:
▪︎ lk CLI: lk dispatch create --room my-room --agent-name VoiceAssistantAgent
▪︎ Or use the server API that creates a dispatch for that agent name and room.
1. Verify the agent joins
◦ Watch the agent logs after dispatch. You should see the agent receive the dispatch and connect to the room.
◦ Confirm in your LiveKit room that the agent participant is present.
Troubleshooting if the agent still does not join
• Agent not connected: Confirm the agent process shows a successful registration and is reachable by LiveKit.
• Name mismatch: Ensure the dispatch uses exactly VoiceAssistantAgent (case-sensitive).
• Network/connectivity: Make sure the agent host can reach your LiveKit server (check URLs, ports, TLS).
• Dispatch rejected or errors: Share the agent log lines around the time you triggered dispatch and any CLI/API response messages — I can help interpret them.
If you want, paste:
• The exact agent startup log lines, and
• The dispatch command or API call and its response —
and I’ll walk through the logs and the dispatch command with you to find the blocker.nutritious-businessperson-79241
03/15/2026, 1:16 PMtall-airline-16756
03/15/2026, 1:17 PM@server.rtc_session(agent_name="VoiceAssistantAgent")
async def my_agent(ctx: JobContext):
print(f"Agent joined room: {ctx.room.name}")
• The agent_name in code is case-sensitive and must match exactly what you dispatch.
3) Start the agent process (must be running before dispatch)
• Run the agent so it registers with LiveKit. Example dev command:
uv run agent.py dev
• Check the agent terminal/logs for a confirmation like “registered worker” or other startup messages. If you don’t see registration, check LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET environment variables and network connectivity to your LiveKit server.
4) Dispatch the agent to a room
• CLI (quickest test):
lk dispatch create --agent-name VoiceAssistantAgent --room my-test-room
This will create the room if needed and request LiveKit dispatch the named agent to it.
• API (programmatic):
Use the LiveKit API to create an agent dispatch specifying agent_name and room. Your API call should match the agent name exactly.
5) Verify the agent joined
• Check agent logs right after dispatch. You should see something like:
Agent joined room: my-test-room
or other log lines from your entrypoint function.
• LiveKit Dashboard: open the room and look for a participant of type AGENT.
• Add explicit logging in the agent entrypoint if needed:
@server.rtc_session(agent_name="VoiceAssistantAgent")
async def my_agent(ctx: JobContext):
print(f"✅ Agent is now in room: {ctx.room.name}")
6) Common reasons a dispatch fails and how to fix
• Agent process not running: start it and confirm registration.
• Name mismatch: ensure dispatch uses exactly "VoiceAssistantAgent".
• Network/firewall issues: ensure agent host can reach your LiveKit server (check ports and TLS).
• Dispatch command returns success but agent doesn’t respond: check agent logs for errors or exceptions.
• Room connection times out: ensure your agent’s code handles connection and does not exit immediately on startup errors.
7) If you want a quick test flow to confirm everything works
1. Start agent in one terminal:
◦ uv run agent.py dev
1. In another terminal, dispatch:
◦ lk dispatch create --agent-name VoiceAssistantAgent --room test-room
1. Watch agent logs; you should see join confirmation.
8) If it still doesn’t join, please share
• The exact dispatch command (or API request) you ran and its response.
• The relevant agent startup log lines (especially register/startup and any errors).
• The agent_name string from your code (exactly as written).
Share those and I’ll read the logs/command output and tell you exactly what to fix.
Sources: Build Your First AI Voice Agent in Python: Complete Tutorial | LiveKit | examples/drive-thru | livekit/livekit_composite | DeepWiki | Agent dispatch | LiveKit Documentation | Agents Framework | livekit/livekit_composite | DeepWikinutritious-businessperson-79241
03/15/2026, 1:20 PMtall-airline-16756
03/15/2026, 1:20 PM