bitter-cpu-44145
10/31/2025, 2:49 PMtall-airline-16756
10/31/2025, 2:50 PMtall-airline-16756
10/31/2025, 2:51 PM--id flag to specify the agent ID during creation or deployment. For example: lk agent create --id AG_xxxxxxxxxxxxx. This way, you’re telling the system exactly which agent you want to work with.
• Configuration File: Another approach is to use a livekit.toml file where you define the agent configuration, including its ID. It’s a neat way to keep things organized.
• Application-Level Dispatch: Within your application code, you can specify the agent by using the room_config parameter. For example, include agents: [{ agent_name: 'desired_agent_name' }] in your configuration. This helps you control agent assignment right where your app logic lives.
• Token-Based Dispatch: You can configure a participant's token to include specific agents in the RoomConfiguration. This gives you flexibility at the participant level.
• API Dispatch: If you prefer programmatic control, the Agent Dispatch API allows you to explicitly assign agents to rooms. It’s perfect for dynamic scenarios.
If you’d like, I’m here to provide more details or examples for any of these methods—just let me know!
Sources: Agent dispatch | LiveKit Docs | examples/agent_dispatch.py | packages/livekit-server-sdk/src/AgentDispatchClient.ts | Agent deployment CLI reference | LiveKit Docs | CLI Tools & Token Management | livekit/livekit_composite | DeepWikibitter-cpu-44145
10/31/2025, 2:55 PMtall-airline-16756
10/31/2025, 2:55 PMconst agentDispatchClient = new AgentDispatchClient(process.env.LIVEKIT_URL);
const dispatch = await agentDispatchClient.createDispatch(
'my-room',
'test-agent',
{
metadata: '{"mydata": "myvalue"}',
}
);
console.log('created dispatch', dispatch);
Another friendly tip: you can also dispatch an agent automatically when a participant joins a room by including the agent in the participant's access token configuration. Here’s how you might do that in Python:
token = (
api.AccessToken()
.with_identity("my_participant")
.with_grants(api.VideoGrants(room_join=True, room=room_name))
.with_room_config(
api.RoomConfiguration(
agents=[api.RoomAgentDispatch(agent_name="test-agent", metadata="my_metadata")],
),
)
.to_jwt()
)
If you'd like, I’m here to provide more details or examples in any other programming language you prefer. Just let me know!
Sources: examples/agent_dispatch/README.md | Agent dispatch | LiveKit Docs | Job lifecycle | LiveKit Docs | packages/livekit-server-sdk/src/AgentDispatchClient.ts | examples/agent_dispatch.py