can i create 2 agents, one agent that asks questio...
# ask-ai
p
can i create 2 agents, one agent that asks question and another agent that replies to the questions asked by the bot and i as the viewer can listen to these 2 bots conversing?? can we do that?? so that in room there are 3 participants 2 bots and one user. how to do this??
t
Thanks for reaching out, Aaron. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes — you can run two agents (bots) that talk to each other while you join as a third participant and listen. Below I’ll walk through the essentials and a simple implementation outline so you can get this running. Quick acknowledgement • You want a room with three participants: Agent A (asks questions), Agent B (answers), and a human user who listens. I’ll explain what must be enabled and the simple steps to get both agents to hear and respond to each other. What needs to be true • Both agents must be allowed to receive audio from other agents. By default agents don’t listen to other agents, so you must enable agent-to-agent audio in the room options. • Each agent needs STT (speech-to-text), an LLM for response generation, and TTS (text-to-speech) to speak. • One agent should initiate the conversation (or be triggered to start), and the other should be able to detect and respond to that audio. High-level steps 1. Create two agent programs (Agent A = Questioner, Agent B = Responder). 2. When starting each agent session, set RoomOptions to include
PARTICIPANT_KIND_AGENT
so agents receive audio from other agents. 3. Ensure each agent has STT, an LLM, and TTS configured so they can hear, process, and speak. 4. Start both agents so they join the same LiveKit room. 5. Have the Questioner start (explicit initial prompt or generate_reply); Responder will hear, process, and reply. 6. Join the room as a regular user (Web SDK, mobile, or other client) to listen to both agents’ audio tracks. Minimal code outline (conceptual) • Define Agent A (questioner) with instructions to start by asking a question. • Define Agent B (responder) with instructions to listen and answer. • Start each agent session with RoomOptions that include agents as allowed participant kinds. Example for enabling agent-to-agent audio (conceptual snippet)
Copy code
from livekit.agents import RoomOptions
from livekit import rtc

room_options = RoomOptions(
    participant_kinds=[
        rtc.ParticipantKind.PARTICIPANT_KIND_STANDARD,  # user
        rtc.ParticipantKind.PARTICIPANT_KIND_AGENT      # other agents
    ]
)

# start sessions for each agent using the room_options above
Orchestration tips • Let one agent explicitly generate the first prompt (so they don’t both start at once). • Add a short delay or use simple turn-taking logic to avoid overlapping speech. • Monitor agent audio activity and use VAD or session events to trigger replies only after speech ends. How you (the user) listen • Join the same LiveKit room as a standard participant (browser or mobile). The agents publish audio tracks to the room, so you’ll hear both bots as they speak. When you might need to adjust • If you want more natural turn-taking, add logic to detect when an agent has finished speaking before prompting the other. • If you want multiple rounds, implement a simple conversation state so they don’t loop or talk over each other. If you’d like, I can: • Show a concrete code example for Agent A and Agent B (Python) with STT/LLM/TTS placeholders. • Suggest a simple turn-taking pattern (example code) to prevent overlaps. • Help you map this to the SDK you plan to use (Web / mobile / Python agent runtime). Which would you prefer next — a full Python example with agent classes and session start code, or a short turn-taking snippet to prevent overlapping speech? Sources: How to Test Your Agent Using Another Agent | LiveKit | Introduction | LiveKit Documentation | Agent speech and audio | LiveKit Documentation | Agents (Python) | livekit/livekit_composite | DeepWiki | livekit/livekit_composite | DeepWiki
p
i am going to use deepgram for stt and tts for both the bots but with different voices to differentiate and groq as the llm llama-3.1-8b-instant model, use this and show me detailed example on how to completely build this, and yes i need turn taking patterns also an additional feature i want is when i the viewer start to talk the question asking bot should be silent and the answer bot should listen to my quesiton and respond to my question as well and once i have got the answer for my question the question asking bot can continue with the question lets set a question limit of 5 so that that bot doesnt forever keep asking questions. give me the full code
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
p
give me the names of the events that can be used when identifying one bot has finished speaking so that the other bot can start talking