how to add two agents in one room
# ask-ai
l
how to add two agents in one room
t
Thanks for reaching out, Rajadurai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you want to add two agents to the same room. Here’s how to do that. 1. Add both agents to the room dispatch configuration ◦ When creating the room (or the access token’s room configuration), include both agents in the
agents
list using
RoomAgentDispatch
. Example:
Copy code
token.room_config = RoomConfiguration(
     max_participants=10,
     agents=[
       RoomAgentDispatch(agent_name="agent-one"),
       RoomAgentDispatch(agent_name="agent-two"),
     ]
   )
1. Or dispatch each agent programmatically to the same room ◦ Call the server SDK’s dispatch/create API for
agent-one
with the target room name, then call it again for
agent-two
with the same room name. 1. Ensure agents can hear each other (optional) ◦ If you want agents to process each other’s audio, start the session with
RoomInputOptions
that includes
PARTICIPANT_KIND_AGENT
so agent audio is included for VAD/STT:
Copy code
await session.start(
     agent=agent,
     room=room_name,
     room_input_options=RoomInputOptions(
       participant_kinds=[rtc.ParticipantKind.PARTICIPANT_KIND_AGENT]
     )
   )
1. Run each agent as its own worker (or one worker handling multiple agents) ◦ Each agent should have a unique
agent_name
and a running worker so LiveKit can dispatch them to the room. If you’d like, tell me: • which SDK/language you’re using (Python, Kotlin, JS), and • whether you want agents to hear/process each other’s audio, and I’ll give a concrete code example for your environment. Sources: LiveKit Docs | server-sdk-kotlin | livekit/livekit_composite | DeepWiki | Outbound Calling Script | LiveKit docs | How to test your agent using another agent | How to Enable Agent-to-Agent Speech Detection in LiveKit
l
I want to two agent debating each other and a SIP or web participant lisinenig on that agents. how to do this
t
Thanks — sounds good. Before I give a step‑by‑step example, which SDK/language are you using (Python, JavaScript, Kotlin, or other)? Also confirm: • Do you want the SIP/web participant to be listen‑only (no mic), or able to speak as well? • Should agents hear each other and be processed for STT/VAD (agents debating), or only send audio to the listener? Answer these and I’ll provide a concrete configuration and sample code.
l
use python framwork. 1. if possible add option to mic 2. use diffrent STT and VAD for two agents
t
Great — I’ll show a concise Python approach to: • Run two agents in the same room with different STT/VAD settings • Have a SIP or web participant join as a listener with optional mic • Ensure agents hear each other so they can debate I’ll give a short flow plus focused code snippets you can adapt. 1) Create the room and dispatch both agents • Include both agents in the room configuration so LiveKit dispatches them to the same room.
Copy code
from livekit_server_sdk import AccessToken, RoomConfiguration, RoomAgentDispatch

token = AccessToken(api_key, api_secret)
token.room_config = RoomConfiguration(
    max_participants=10,
    agents=[
        RoomAgentDispatch(agent_name="agent_one"),
        RoomAgentDispatch(agent_name="agent_two"),
    ],
)
room_token = token.to_jwt()
# Use room_token to create/join the room on the server side
2) Start each agent worker with its own STT/VAD config • Each agent process/worker sets its own
RoomInputOptions
(or equivalent) so STT and VAD differ per agent. • Ensure
participant_kinds
includes
PARTICIPANT_KIND_AGENT
so agents receive each other’s audio. Example agent startup (pseudo-Python; adapt to your agent runtime API):
Copy code
from livekit_agents import AgentSession, RoomInputOptions, rtc

agent_name = "agent_one"   # change for agent_two
stt_config = {"provider":"sttA", "model":"modelA"}   # per-agent STT
vad_config = {"threshold":0.5, "mode":"aggressive"}  # per-agent VAD

session = AgentSession(
    agent_name=agent_name,
    room=room_name,
    stt=stt_config,
    vad=vad_config,
)

session.start(
    room_input_options=RoomInputOptions(
        participant_kinds=[rtc.ParticipantKind.PARTICIPANT_KIND_AGENT]
    )
)
Run a second worker/process with
agent_name="agent_two"
and different `stt_config`/`vad_config`. 3) Listener (SIP or web participant) with optional mic • For a listen-only web participant: join the room without publishing audio. • For a web participant with optional mic: allow publish of microphone tracks based on user choice. • For SIP: create a SIP participant or SIP gateway join; configure RTP direction to receive only (or send/receive if mic allowed). Web (browser) listener example behavior: • If listen-only: do not call
publishTrack
for mic. • If mic enabled: capture mic and publish the audio track. SIP example (high-level): • Create SIP participant via API (or SIP gateway) into the same room. • To be listen-only: configure the SIP endpoint to receive audio only. • To allow mic: enable send audio from SIP side. 4) Important details and checks • Agents must run as separate workers (or processes) with distinct `agent_name`s so each can have its own config. • Use
participant_kinds=[PARTICIPANT_KIND_AGENT]
so agent audio is included for agent-side STT/VAD. • Ensure your STT/VAD integration hooks receive per-agent audio streams and apply the correct config in each worker. If you want, I can now: • Provide a complete runnable Python example for the agent worker (choose which agent SDK/library you’re using), or • Show the exact browser/SIP join code for the listener (WebRTC or SIP gateway) depending on which you’ll use. Which would you like next: full agent worker code (pick agent SDK) or listener join code (web or SIP)?