little-car-50043
09/26/2025, 8:52 PMtall-airline-16756
09/26/2025, 8:52 PMtall-airline-16756
09/26/2025, 8:52 PMAgentDispatchService to send out multiple agents by calling create_dispatch() for each agent name. Here's a simple example:
import asyncio
from livekit import api
async def dispatch_multiple_agents():
lkapi = api.LiveKitAPI()
room_name = "my-room"
agent_names = ["agent-1", "agent-2", "agent-3"]
for name in agent_names:
dispatch = await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name=name,
room=room_name,
metadata='{"purpose": "multi-agent-demo"}'
)
)
print(f"Dispatched {name} to {room_name}: {dispatch}")
await lkapi.aclose()
asyncio.run(dispatch_multiple_agents())
Method 2: Dispatch Multiple Agents via Participant Token
Another approach is to set up a participant’s access token to automatically dispatch multiple agents when they connect. You can do this by adding multiple RoomAgentDispatch entries in the RoomConfiguration. Here's how it looks:
from livekit.api import (
AccessToken,
RoomAgentDispatch,
RoomConfiguration,
VideoGrants,
)
def create_token_with_multiple_agents():
token = (
AccessToken()
.with_identity("user123")
.with_grants(VideoGrants(room_join=True, room="my-room"))
.with_room_config(
RoomConfiguration(
agents=[
RoomAgentDispatch(agent_name="transcription-agent", metadata='{"role": "transcriber"}'),
RoomAgentDispatch(agent_name="summarization-agent", metadata='{"role": "summarizer"}'),
RoomAgentDispatch(agent_name="moderation-agent", metadata='{"role": "moderator"}'),
],
),
)
.to_jwt()
)
return token
# Usage
token = create_token_with_multiple_agents()
print("Generated token:", token)
If you have any questions or want me to walk you through any part of this, please don’t hesitate to ask. I’m here to help!
Sources: Docs::Agents | How to Enable Agent-to-Agent Speech Detection in LiveKitlittle-car-50043
09/26/2025, 9:24 PMtall-airline-16756
09/26/2025, 9:24 PMagent_name.
For instance, using the AgentDispatchService, you can create multiple dispatches for the same room like this:
await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(agent_name="agent1", room="my-room")
)
await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(agent_name="agent2", room="my-room")
)
This way, you’re assigning two different workers (for example, agent1 and agent2) to the same room.
Just a quick note: by default, automatic dispatch assigns only one agent per room, so to have multiple workers, explicit dispatch is the way to go. Also, if you want your agents to communicate with each other, you can set RoomInputOptions.participant_kinds = [rtc.ParticipantKind.PARTICIPANT_KIND_AGENT].
If you have any questions or need a hand with this, just let me know—I’m here to help!
Sources: Docs::Agents | How to Enable Agent-to-Agent Speech Detection in LiveKit | Agent dispatch | LiveKit Docslittle-car-50043
09/26/2025, 9:37 PMasync def entrypoint(ctx: JobContext, agent_identity: str | None = "agent"):
avatar_options = AvatarOptions(...)
video_gen = ...
runner = AvatarRunner(
room,
audio_recv=DataStreamAudioReceiver(
room,
sender_identity=agent_identity
),
video_gen=video_gen,
options=avatar_options,
)tall-airline-16756
09/26/2025, 9:37 PMhedra.AvatarSession can't be used as a substitute for video_gen in AvatarRunner, as they actually serve different purposes and operate at different levels:
• video_gen in AvatarRunner is a VideoGenerator implementation that creates video frames based on audio input.
• hedra.AvatarSession is a higher-level integration connecting to Hedra's API to animate avatars, and it works alongside AgentSession, not AvatarRunner.
To use Hedra avatars smoothly, you’ll want to integrate hedra.AvatarSession with AgentSession like this:
session = AgentSession(...)
avatar = hedra.AvatarSession(avatar_image=image)
await avatar.start(session, room=ctx.room)
await session.start(...)
If anything’s unclear or if you’d like a hand with this, please don’t hesitate to reach out—I’m here to help!
Sources: examples/avatar_agents/audio_wave/avatar_runner.py | Hedra Realtime Avatar integration guide | LiveKit Docs | Docs::Agentslittle-car-50043
09/26/2025, 9:38 PMtall-airline-16756
09/26/2025, 9:39 PMhedra.AvatarSession can indeed run as a separate worker in LiveKit. Think of the avatar worker as its own participant in the room, happily publishing synchronized audio and video tracks on behalf of the main agent session.
To get this going, you’d start the AvatarSession alongside the AgentSession and the room context. The agent session sends its audio output over to the avatar worker, which then takes care of rendering and publishing it to the room. You’ll recognize the avatar worker as a participant with kind agent and the attribute lk.publish_on_behalf.
If you’d like, I’m here to help you step through the setup or answer any questions you might have!
Sources: Virtual avatar integrations | LiveKit Docs | Hedra Realtime Avatar integration guide | LiveKit Docs | Docs::Agents | livekit-plugins/livekit-plugins-hedra/README.mdlittle-car-50043
09/26/2025, 9:44 PMtall-airline-16756
09/26/2025, 9:45 PMRoomAgentDispatch entries in the RoomConfiguration while generating the participant’s access token. Here’s a friendly example in Python to guide you through:
from livekit.api import AccessToken, RoomAgentDispatch, RoomConfiguration, VideoGrants
token = (
AccessToken()
.with_identity("participant")
.with_grants(VideoGrants(room_join=True, room="my-room"))
.with_room_config(
RoomConfiguration(
agents=[
RoomAgentDispatch(agent_name="agent1", metadata='{"role": "moderator"}'),
RoomAgentDispatch(agent_name="agent2", metadata='{"task": "transcription"}'),
]
)
)
.to_jwt()
)
print("Generated token:", token)
Each RoomAgentDispatch lets you specify an agent_name and optional metadata to provide context to the agent. This way, the token will dispatch the agents you’ve specified as soon as the participant connects to the room.
If you have any questions or need a hand with anything else, please don’t hesitate to ask—I’m here to help!
Sources: Docs::Agents