I am trying to add multiple agent in same room wit...
# ask-ai
s
I am trying to add multiple agent in same room with different voice for different work. Its not listening to what i say but replies in parallel when i type in message. Whats the possible solution?
t
Thanks for reaching out, Rishabh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
If you want to add multiple agents in the same room, each with their own unique voice for different tasks, you can totally do that by setting up agent handoff and assigning different Text-to-Speech (TTS) voices to each one. Here’s a simple way to get it done: • Dispatch multiple agents to the same room by adding several
RoomAgentDispatch
entries in your
RoomConfiguration
. • Use agent handoff so agents can smoothly pass control to one another when needed. • Give each agent a unique TTS voice by configuring their voice IDs—Cartesia TTS works great for setting distinct voices for each agent. • Turn on speech detection between agents by including
rtc.ParticipantKind.PARTICIPANT_KIND_AGENT
in the
participant_kinds
within
RoomInputOptions
. This way, each agent can focus on what they do best while keeping the conversation flowing naturally with shared user data or chat history. If you want, I’m here to help you set it all up—just let me know! Sources: examples/other/translation/multi-user-translator.py | main.py | How to Enable Agent-to-Agent Speech Detection in LiveKit | Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs
s
const micPub = room.localParticipant.getTrackPublication(Track.Source.Microphone); const micSid = micPub?.trackSid; room.localParticipant.setTrackSubscriptionPermissions(false, [ { participantIdentity: ids.agenttwo, ...(to === 'agent-2' ? micSid ? { allowedTrackSids: [micSid] } : { allowAll: true } : { allowedTrackSids: [] }), }, { participantIdentity: ids.agenttwo, ...(to === 'agent-2' ? micSid ? { allowedTrackSids: [micSid] } : { allowAll: true } : { allowedTrackSids: [] }), }, ]);
t
The
setTrackSubscriptionPermissions
method is a handy way to decide who gets to subscribe to your published tracks. Here’s a quick rundown: • allParticipantsAllowed: Set this to
false
if you want to keep things locked down by default. • trackPermissions: Here, you can specify exact permissions for each participant using
ParticipantTrackPermission
objects. Each one can include: ◦ `participantIdentity`: Who the participant is. ◦ `allowAll`: If set to
true
, that participant can access all tracks. ◦ `allowedTrackSids`: A list of specific track SIDs that participant can subscribe to. In your code, you’re setting permissions dynamically for two agents depending on certain conditions. Just double-check that: • The
micSid
is grabbed correctly and matches the track you want to allow. • Each participant’s permissions are clearly laid out in the
trackPermissions
array. If anything’s unclear or you want a hand debugging, just give me a shout—I’m here to help! Sources: packages/livekit-rtc/src/proto/track_pb.ts | Camera & microphone | LiveKit Docs | lib/src/proto/livekit_rtc.pb.dart | src/room/participant/ParticipantTrackPermission.ts | Sources/LiveKit/Participant/LocalParticipant.swift