faint-arm-51818
11/10/2025, 5:19 PMtall-airline-16756
11/10/2025, 5:19 PMtall-airline-16756
11/10/2025, 5:20 PMRoomInputOptions when you start the agent session. Here's a simple example to guide you:
await session.start(
agent=SimpleEvaluationAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(
participant_kinds=[
rtc.ParticipantKind.PARTICIPANT_KIND_AGENT,
]
),
)
If you're looking for an easier setup, you can also use listen_to_agents=True. This makes sure your agent listens to and processes input from other agents in the room.
For the best results, I recommend using isolated rooms for each test, defining clear personas and conversation scripts, and integrating these tests into your CI/CD pipelines. If you'd like, there's a full implementation example available in the LiveKit agents repository that you might find really helpful.
Sources: How to test your agent using another agent | Agent Testing & CI/CD | livekit/livekit_composite | DeepWiki | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | docs/index.yaml | README.mdfaint-arm-51818
11/10/2025, 5:32 PMtall-airline-16756
11/10/2025, 5:34 PMfrom livekit.api import AccessToken, VideoGrants, RoomConfiguration, RoomAgentDispatch
# Create an access token
api_key = "your-api-key"
api_secret = "your-api-secret"
token = AccessToken(api_key=api_key, api_secret=api_secret)
token.identity = "participant-identity"
token.add_grant(VideoGrants(room_join=True, room="my-room"))
# Dispatch two agents to the same room
token.with_room_config(
RoomConfiguration(
agents=[
RoomAgentDispatch(agent_name="conversation-agent", metadata="agent1-data"),
RoomAgentDispatch(agent_name="moderator-agent", metadata="agent2-data"),
]
)
)
# Generate the token
jwt_token = token.to_jwt()
print("Token:", jwt_token)
When you use this token to join the room, both agents will be dispatched automatically. Pretty neat, right?
Node.js Example:
import { RoomAgentDispatch, RoomConfiguration } from '@livekit/protocol';
import { AccessToken } from 'livekit-server-sdk';
const at = new AccessToken();
at.identity = 'my-participant';
at.addGrant({ roomJoin: true, room: 'my-room' });
at.roomConfig = new RoomConfiguration({
agents: [
new RoomAgentDispatch({
agentName: "conversation-agent",
metadata: "agent1-data"
}),
new RoomAgentDispatch({
agentName: "moderator-agent",
metadata: "agent2-data"
})
]
});
const token = await at.toJwt();
console.log("Token:", token);
If you're interested in more advanced setups, you can also use the Agent Dispatch API to explicitly dispatch agents after the room is created. Feel free to reach out if you'd like me to guide you through that or if you have any other questions. I'm here to help!
Sources: Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | How to Enable Agent-to-Agent Speech Detection in LiveKit | Job lifecycle | LiveKit Docs | Agent dispatch | LiveKit Docs | Authentication | LiveKit Docsfaint-arm-51818
11/10/2025, 5:50 PMtall-airline-16756
11/10/2025, 5:50 PMfrom livekit.agents import (
Agent,
AgentSession,
JobContext,
WorkerOptions,
cli,
)
from livekit.plugins import deepgram, openai, silero
# Agent 1 - Conversation Handler
async def conversation_agent_entrypoint(ctx: JobContext):
await ctx.connect()
agent = Agent(
instructions="You are a helpful conversation assistant.",
)
session = AgentSession(
vad=silero.VAD.load(),
stt=deepgram.STT(model="nova-3"),
llm=openai.LLM(model="gpt-4o-mini"),
tts=openai.TTS(voice="echo"),
)
await session.start(agent=agent, room=ctx.room)
# Agent 2 - Moderator
async def moderator_agent_entrypoint(ctx: JobContext):
await ctx.connect()
agent = Agent(
instructions="You are a room moderator. Monitor conversations and provide guidance.",
)
session = AgentSession(
vad=silero.VAD.load(),
stt=deepgram.STT(model="nova-3"),
llm=openai.LLM(model="gpt-4o-mini"),
tts=openai.TTS(voice="nova"),
)
await session.start(agent=agent, room=ctx.room)
# Register Agent 1
if __name__ == "__main__":
cli.run_app(WorkerOptions(
entrypoint_fnc=conversation_agent_entrypoint,
agent_name="conversation-agent" # Unique agent name
))
# Register Agent 2 (run separately)
if __name__ == "__main__":
cli.run_app(WorkerOptions(
entrypoint_fnc=moderator_agent_entrypoint,
agent_name="moderator-agent" # Unique agent name
))
Each agent is set up with its own entrypoint function and a unique name, which helps keep things organized. You can run these agents in separate processes, and they’ll connect to the same room seamlessly. If anything feels unclear or if you'd like me to provide more examples, please don’t hesitate to ask—I’m here to help!