freezing-jelly-85538
09/12/2025, 6:47 PMawait self.client.room.create_room(
CreateRoomRequest(
name=input.room_name,
departure_timeout=5,
empty_timeout=15,
max_participants=3,
egress=input.egress_config,
metadata=json.dumps(input.metadata),
)
)
at = AccessToken(self.api_key, self.api_secret)
grants = VideoGrants(
room=input.room_name,
room_join=True,
can_publish=True,
can_publish_data=True,
can_subscribe=True,
can_update_own_metadata=True,
)
with_grants = at.with_grants(grants)
with_identity = with_grants.with_identity(input.user_id)
with_name = with_identity.with_name(input.user_name)
access_token = with_name.to_jwt()
tall-airline-16756
09/12/2025, 6:47 PMtall-airline-16756
09/12/2025, 6:48 PMagent_name
in its WorkerOptions
, the automatic dispatch gets disabled, so you’ll need to trigger the dispatch explicitly.
If you want to explicitly dispatch an agent during room creation, you can include a RoomConfiguration
with RoomAgentDispatch
in the participant’s access token. For instance, by setting agents=[RoomAgentDispatch(agent_name="test-agent")]
in the RoomConfiguration
, the agent named "test-agent" will be dispatched as soon as the participant joins and the room is created.
Please don’t hesitate to reach out if you’d like me to walk you through this setup or if you have any other questions—I’m here to support you!
Sources: livekit-api/tests/test_access_token.py | Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | Authentication | LiveKit Docs | spec/livekit/access_token_spec.rbfreezing-jelly-85538
09/12/2025, 6:49 PMawait self.client.room.create_room(
CreateRoomRequest(
name=input.room_name,
departure_timeout=5,
empty_timeout=15,
max_participants=3,
egress=input.egress_config,
metadata=json.dumps(input.metadata),
)
)
at = AccessToken(self.api_key, self.api_secret)
grants = VideoGrants(
room=input.room_name,
room_join=True,
can_publish=True,
can_publish_data=True,
can_subscribe=True,
can_update_own_metadata=True,
)
with_grants = at.with_grants(grants)
with_identity = with_grants.with_identity(input.user_id)
with_name = with_identity.with_name(input.user_name)
with_room_config = with_name.with_room_config(
RoomConfiguration(
agents=[RoomAgentDispatch(agent_name=input.agent_name)],
)
)
access_token = with_room_config.to_jwt()
tall-airline-16756
09/12/2025, 6:50 PMRoomAgentDispatch
in RoomConfiguration
doesn’t actually enable automatic agent dispatch. Instead, it works by triggering a specific dispatch when a participant connects to the room. If your agent has an agent_name
set in its WorkerOptions
, automatic dispatch is intentionally turned off, so dispatching needs to be triggered explicitly.
When you include RoomAgentDispatch
in the access token, it means the specified agent will be dispatched right when the participant joins the room. Just to clarify, this doesn’t turn automatic dispatch back on; it simply allows for targeted, on-demand dispatch of that particular agent.
If this doesn’t quite match what you were expecting, please don’t hesitate to reach out. I’m here to help you with your setup or explore other options that might work better for you.
Sources: Agent dispatch | LiveKit Docs | Dispatching agents | LiveKit Docs | Agents telephony integration | LiveKit Docs | examples/agent-dispatch/index.ts | examples/agent_dispatch.pyfreezing-jelly-85538
09/12/2025, 6:51 PMtall-airline-16756
09/12/2025, 6:51 PMRoomAgentDispatch
, rather than it being the default for all agents.
True automatic dispatch, in the strictest sense, happens without any special configuration and only applies to agents who don’t have an agent_name
set in their WorkerOptions
. When you do set an agent_name
, dispatch becomes more intentional and requires the kind of explicit setup you’re already using.
If you’d like, I’m here to help clarify anything further or assist you in fine-tuning this setup. Just let me know!freezing-jelly-85538
09/12/2025, 6:51 PMtall-airline-16756
09/12/2025, 6:52 PMagent_name
set in its WorkerOptions
. Keep in mind, automatic dispatch is turned off when agent_name
is set, but you can still use explicit dispatch.
2. Check that the participant’s token includes `RoomConfiguration`: It’s important the token contains RoomConfiguration
with a RoomAgentDispatch
entry that has the correct agent_name
.
3. Verify the agent and dispatch names match: Double-check that the agent_name
in the agent worker is the same as the one in the token’s RoomAgentDispatch
.
4. Look into the agent dispatch state: You can use the ListAgentDispatchRequest
to see the agent dispatch state and any jobs linked to it.
5. Take a peek at the logs and dashboard: Checking the LiveKit server logs and dashboard might reveal any errors related to agent dispatch.
If you’d like, I’m happy to walk you through any of these steps or assist further. Just let me know!
Sources: pkg/loadtester/agentloadtester.go | Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | protobufs/livekit_room.protofreezing-jelly-85538
09/12/2025, 7:07 PMfreezing-jelly-85538
09/12/2025, 7:07 PMtoken = (
AccessToken()
.with_identity("my_participant")
.with_grants(VideoGrants(room_join=True, room=room_name))
.with_room_config(
RoomConfiguration(
agents=[
RoomAgentDispatch(agent_name="test-agent", metadata='{"user_id": "12345"}')
],
),
)
.to_jwt()
)
return token
tall-airline-16756
09/12/2025, 7:07 PMVideoGrant
. You can also add a RoomConfiguration
to customize settings like the maximum number of participants or agent dispatch. These settings will take effect when the room is created as the first participant joins.
If any part of this feels unclear or if you’d like a hand walking through the steps, please don’t hesitate to reach out—I’m here to help!
Sources: Docs::Home | packages/livekit-server-sdk/src/AccessToken.test.ts | cmd/lk/token.go | Authentication | LiveKit Docs | Docs::Hometall-airline-16756
09/12/2025, 7:07 PMRoomConfiguration
within the token. This lets you set up important details like the maximum number of participants or agent dispatch settings, which will be applied when the room gets created during the participant’s join process.
If you have any more questions or want me to walk you through this setup, just let me know! I’m here to help.freezing-jelly-85538
09/12/2025, 7:12 PMtall-airline-16756
09/12/2025, 7:13 PMfreezing-jelly-85538
09/12/2025, 7:59 PMfreezing-jelly-85538
09/12/2025, 8:01 PM