Skip to content

Commit 6889a1a

Browse files
docs: add deployment field documentation for agent dispatch (#722)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b279ae8 commit 6889a1a

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

examples/agent_dispatch.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
agent_name = "test-agent"
66

77
"""
8-
This example demonstrates how to have an agent join a room
9-
without using the automatic dispatch. In order to use this
10-
feature, you must have an agent running with `agent_name` set
11-
when defining your WorkerOptions. A dispatch requests the
8+
This example demonstrates how to have an agent join a room
9+
without using the automatic dispatch. In order to use this
10+
feature, you must have an agent running with `agent_name` set
11+
when defining your WorkerOptions. A dispatch requests the
1212
agent to enter a specific room with optional metadata.
13+
14+
You can also specify a `deployment` to target a specific agent deployment.
15+
Leave empty to target the production deployment.
1316
"""
1417

1518

@@ -18,7 +21,10 @@ async def create_explicit_dispatch():
1821

1922
dispatch = await lkapi.agent_dispatch.create_dispatch(
2023
api.CreateAgentDispatchRequest(
21-
agent_name=agent_name, room=room_name, metadata="my_metadata"
24+
agent_name=agent_name,
25+
room=room_name,
26+
metadata="my_metadata",
27+
# deployment="staging", # Optional: target a specific deployment
2228
)
2329
)
2430
print("created dispatch", dispatch)
@@ -33,6 +39,9 @@ async def create_explicit_dispatch():
3339
to new rooms. If you want that agent to be dispatched to a new room as soon as
3440
the participant connects, you can set the RoomConfiguration with the agent
3541
definition in the access token.
42+
43+
You can also specify a `deployment` in the RoomAgentDispatch to target a specific
44+
agent deployment. Leave empty to target the production deployment.
3645
"""
3746

3847

@@ -43,7 +52,13 @@ async def create_token_with_agent_dispatch() -> str:
4352
.with_grants(api.VideoGrants(room_join=True, room=room_name))
4453
.with_room_config(
4554
api.RoomConfiguration(
46-
agents=[api.RoomAgentDispatch(agent_name="test-agent", metadata="my_metadata")],
55+
agents=[
56+
api.RoomAgentDispatch(
57+
agent_name="test-agent",
58+
metadata="my_metadata",
59+
# deployment="staging", # Optional: target a specific deployment
60+
)
61+
],
4762
),
4863
)
4964
.to_jwt()

livekit-api/livekit/api/agent_dispatch_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ async def create_dispatch(self, req: CreateAgentDispatchRequest) -> AgentDispatc
3535
To use explicit dispatch, your agent must be registered with an `agentName`.
3636
3737
Args:
38-
req (CreateAgentDispatchRequest): Request containing dispatch creation parameters
38+
req (CreateAgentDispatchRequest): Request containing dispatch creation parameters.
39+
The request can include an optional `deployment` field to target a specific
40+
deployment. Leave empty to target the production deployment.
3941
4042
Returns:
4143
AgentDispatch: The created agent dispatch object

0 commit comments

Comments
 (0)