55agent_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
1212agent 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():
3339to new rooms. If you want that agent to be dispatched to a new room as soon as
3440the participant connects, you can set the RoomConfiguration with the agent
3541definition 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 ()
0 commit comments