narrow-hairdresser-82835
10/15/2025, 5:14 AMif __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm, agent_name='test_agent_name'))
def _create_participant_token(
self,
participant_identity: str,
participant_name: str,
room_name: str,
agent_name: str | None = None,
metadata: dict[str, Any] | None = None,
) -> str:
try:
# Create access token with 15 minute TTL
token = api.AccessToken(self.api_key, self.api_secret)
token.with_identity(participant_identity)
token.with_name(participant_name)
token.with_ttl(timedelta(minutes=15))
if metadata:
metadata_json = json.dumps(metadata)
token.with_metadata(metadata_json)
# Set video grants
grants = api.VideoGrants(
room_join=True,
room=room_name,
can_publish=True,
can_publish_data=True,
can_subscribe=True,
room_record=True,
)
token.with_grants(grants)
if agent_name:
room_config = api.RoomConfiguration(agents=[{"agent_name": agent_name}], departure_timeout=10*60)
token.with_room_config(room_config)
return token.to_jwt()
except Exception as e:
log.exception(f"Failed to create participant token: {e}")
raise
This is my current logictall-airline-16756
10/15/2025, 5:14 AMtall-airline-16756
10/15/2025, 5:16 AMRoomConfiguration and RoomAgentDispatch classes to include the agent name in the token. Here’s an example to guide you:
token.with_room_config(api.RoomConfiguration(agents=[{"agent_name": "test_agent_name"}], departure_timeout=10*60))
1. Set the agent name in the agent class: In your agent worker, make sure to specify the agent_name within the WorkerOptions. Here’s how you can do it:
WorkerOptions(entrypoint_fnc=entrypoint, prewarm_fnc=prewarm, agent_name='test_agent_name')
It’s really important that the agent_name matches exactly in both places — this will turn off automatic dispatch and enable explicit dispatch for you.
If you find the agent still isn’t getting dispatched, double-check that the agent name is consistent and free of typos. And of course, if you have any questions or need a hand, just let me know—I’m here to help!
Sources: livekit-api/livekit/api/agent_dispatch_service.py | SIP troubleshooting guide | LiveKit Docs | Web and mobile frontends | LiveKit Docs | packages/livekit-server-sdk/src/AgentDispatchClient.ts | livekit-agents/livekit/agents/worker.py