red-dentist-96118
11/14/2025, 6:22 PMtall-airline-16756
11/14/2025, 6:22 PMtall-airline-16756
11/14/2025, 6:23 PMagents_allowed=True in the RoomInputOptions or by specifying participant_kinds = [rtc.ParticipantKind.PARTICIPANT_KIND_AGENT]. This setup helps ensure that agents can easily detect and respond to one another within the room.
Sources: Sources/LiveKit/Types/RoomConfiguration.swift | How to Enable Agent-to-Agent Speech Detection in LiveKit | Knowledge Base Content | livekit/livekit_composite | DeepWiki | test/agent_test.go | Agent dispatch | LiveKit Docsred-dentist-96118
11/14/2025, 6:23 PMtall-airline-16756
11/14/2025, 6:24 PMfrom livekit import api
from livekit.proto import RoomConfiguration, RoomAgentDispatch
token = api.AccessToken("api-key", "secret-key")
token.identity = "participant-identity"
token.add_grant(api.VideoGrant(room="my-room", room_join=True))
# Dispatch multiple agents
token.room_config = RoomConfiguration(
agents=[
RoomAgentDispatch(agent_name="transcriber-agent", metadata="{}"),
RoomAgentDispatch(agent_name="summarizer-agent", metadata="{}"),
]
)
jwt_token = token.to_jwt() # Use this token when joining the room
With this setup, both transcriber-agent and summarizer-agent will automatically connect to the room as soon as the participant joins. It’s a neat way to make sure everything’s ready to go!
If you have any questions or want me to walk you through more examples, just let me know—I’m here to help!
Sources: Authentication & Token Management | livekit/livekit_composite | DeepWiki | README.md | Building Multi-Agent Architectures with LiveKit Agents | Knowledge Base Content | livekit/livekit_composite | DeepWiki | Agent dispatch | LiveKit Docsred-dentist-96118
11/14/2025, 6:24 PMtall-airline-16756
11/14/2025, 6:25 PMRoomInputOptions to include agent participants:
RoomInputOptions.participant_kinds = [rtc.ParticipantKind.PARTICIPANT_KIND_AGENT]
This setup allows agents to hear and respond to each other naturally, especially when text-to-speech (TTS) is configured properly. It’s a great way to have seamless two-way conversations.
2. Task Delegation:
Agents can use the function_tool to call functions on other agents or transfer control. For example, an intake agent can collect user info and then pass it to a specialist agent for more detailed assistance. This helps keep things organized and efficient.
3. Data and Control Communication:
Agents can exchange data messages and control signals through LiveKit’s data channels. This includes:
4. Context Sharing:
Using the UserData class, agents can share important context like user details during handoffs. This ensures interactions stay stateless and scalable, making the process even more reliable.
These wonderful tools work together to support complex workflows and help agents collaborate in real-time. If you’d like, I’m here to provide more details or examples—just let me know!
Sources: How to Enable Agent-to-Agent Speech Detection in LiveKit | Building Multi-Agent Architectures with LiveKit Agents | README.md | complex-agents/note-taking-assistant/README.md | AI Agents Framework | livekit/livekit_composite | DeepWikired-dentist-96118
11/14/2025, 6:26 PMtall-airline-16756
11/14/2025, 6:27 PMchat_ctx (chat context) along. This way, the new agent gets the conversation history without needing to resend those large prompts. For example:
return TechnicalSupportAgent(chat_ctx=self.session.chat_ctx)
2. Truncate and Filter Context:
You can keep things neat by truncating the context to only the most relevant messages. Here’s how you might do that in JavaScript:
const truncatedChatCtx = userdata.prevAgent.chatCtx
.copy({
excludeInstructions: true,
excludeFunctionCall: false,
})
.truncate(6);
This approach keeps just the last 6 messages and skips any unnecessary instructions.
3. Deduplicate Context:
To prevent sending duplicate messages, you can add some deduplication logic like this:
const existingIds = new Set(chatCtx.items.map((item) => item.id));
const newItems = truncatedChatCtx.items.filter((item) => !existingIds.has(item.id));
chatCtx.items.push(...newItems);
4. Summarize Context:
Another helpful tip is to summarize the conversation history and include that summary in the new agent’s instructions. This reduces redundancy nicely:
chat_ctx.add_message(
role="system",
content=f"You are the {agent_name}. {userdata.summarize()}"
)
By using these methods, you can keep your handoffs efficient while maintaining a smooth and continuous conversation. If any part feels unclear or you’d like more examples, just let me know—I’m happy to help!
Sources: Workflows | LiveKit docs | examples/src/restaurant_agent.ts | complex-agents/medical_office_triage/README.md | Live Conversations with AI using ChatGPT and WebRTC | AI-Powered Change Summarization | livekit/livekit_composite | DeepWiki