brief-analyst-2675
09/21/2025, 4:22 PMtall-airline-16756
09/21/2025, 4:22 PMtall-airline-16756
09/21/2025, 4:22 PMbrief-analyst-2675
09/21/2025, 4:23 PMtall-airline-16756
09/21/2025, 4:24 PMAgentDispatchService to create a dispatch request for your agent to join a specific room. Here’s a simple example:
import asyncio
from livekit import api
async def create_explicit_dispatch():
lkapi = api.LiveKitAPI()
dispatch = await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name="test-agent", # Make sure this matches agent_name in WorkerOptions
room="my-room", # The room you want the agent to join
metadata="my_metadata"
)
)
print("created dispatch", dispatch)
await lkapi.aclose()
asyncio.run(create_explicit_dispatch())
1. Dispatch via Participant Token: Another way is to include the agent dispatch in the room configuration when you generate the participant's access token. Here’s how you can do it:
token = (
api.AccessToken()
.with_identity("my_participant")
.with_grants(api.VideoGrants(room_join=True, room="my-room"))
.with_room_config(
api.RoomConfiguration(
agents=[
api.RoomAgentDispatch(
agent_name="test-agent",
metadata="my_metadata"
)
],
),
)
.to_jwt()
)
Just a couple of important things to double-check:
• Make sure the agent_name in your dispatch request exactly matches what you have set in WorkerOptions.
• Verify that your LiveKit server URL, API key, and secret are all correctly configured.
Also, it’s a good idea to confirm the agent’s registration and worker status by:
• Looking at the WebSocket connection logs for messages like "starting worker".
• Using the worker’s health check endpoint to see if it’s registered properly.
• Ensuring the worker process is running smoothly without any errors.
If you’d like, I’m here to help you review your setup or take a look at any logs. Just let me know!
Sources: Dispatching agents | LiveKit Docs | examples/agent_dispatch.py | Agent dispatch | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | livekit-agents/livekit/agents/worker.pybrief-analyst-2675
09/21/2025, 4:25 PMtall-airline-16756
09/21/2025, 4:25 PMbrief-analyst-2675
09/21/2025, 5:02 PMtall-airline-16756
09/21/2025, 5:03 PM