What is the advantage of creating multiple agents ...
# ask-ai
i
What is the advantage of creating multiple agents to handle a single conversation rather than one single agent with a long prompt?
t
Thanks for reaching out, Mathew. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking why use multiple agents for one conversation instead of a single agent with a long prompt — good question. Here are the practical advantages and when to choose multi-agent workflows. • Reliability for multi-step tasks LLMs struggle to consistently follow long, complex multi-step instructions in a single prompt. Breaking the flow into agents lets each agent focus on a simpler, deterministic subtask, improving correctness. • Clear separation of concerns Use different agents for distinct roles or capabilities (e.g., triage vs escalation, moderator vs coach, payment access vs general info). That keeps responsibilities explicit and reduces prompt complexity. • Modular, composable design Agents can be chained with function tools and tasks so you can build, test, and reuse components without reauthoring huge prompts. • Scalability and statelessness Keeping agents stateless and passing session context separately makes the system easier to scale, distribute, and recover from failures. • Easier testing and maintenance Smaller agents are simpler to validate, debug, and upgrade independently; workflows make expected behavior predictable. • Flexible context management and UX control You can choose when to preserve context or start fresh between agents, and announce handoffs to users for a smoother experience. When to prefer a single long prompt: • Very simple conversations with minimal branching or side effects where a single agent can reliably meet requirements. When to prefer multiple agents: • Deterministic business processes, multi-step flows, different tool/permission needs, or when you want easier testing, scaling, and maintainability. Would you like help designing a workflow for a specific use case (e.g., support triage → billing → specialist handoff)? Sources: Building the all-in-one platform for voice AI agents | Agents and handoffs | LiveKit docs | Building Multi-Agent Architectures with LiveKit Agents | Workflows | LiveKit docs
i
If I preserve context won't the prompt get bigger and bigger as it’s handed over from one agent to another?
t
Good question — preserving context can increase the data passed between agents, but you don’t have to append the entire conversation raw each handoff. Here are concise strategies to keep context manageable: • Summarize instead of copy-paste Pass a short, structured summary of prior turns (intent, open tasks, key facts) rather than full transcripts. • Store session state outside prompts Keep long histories in a session store and pass only the relevant keys or small slices of state to agents. • Use structured context objects Send concise fields (e.g.,
user_intent
,
billing_status
,
last_agent_action
) so agents get exactly what they need. • Selective recall Retrieve and include only recent or task-relevant messages when handing off, not every message. • Token-aware pruning Truncate or compress low-value history automatically when token limits are approached. • Use hierarchical workflows Keep high-level orchestration agents that route tasks and lightweight task agents that operate with minimal context. These approaches preserve continuity without letting prompts grow unbounded. Do you want an example structure for summarizing context for handoffs?
i
How does LiveKit manage preserving context?
t
You're asking how LiveKit preserves context across agent handoffs. Here's how it works and the controls you can use. • Default behavior Each new agent starts with a fresh conversation history unless you explicitly pass context from the previous agent. • Explicit handoff with
chat_ctx
Pass the prior agent’s
chat_ctx
into the new agent so it has the conversation history up to that point:
Copy code
return TechnicalSupportAgent(chat_ctx=self.session.chat_ctx)
• Full session history available
session.history
stores the complete interaction log and is accessible to agents regardless of handoffs. • Selective copying and filters Use
chat_ctx.copy()
with options like
exclude_empty_message
,
exclude_instructions
, or
exclude_function_call
to include only relevant parts of history when handing off. • Use cases supported ◦ Preserve full continuity for seamless transitions ◦ Reset context for a clean slate when starting a new phase ◦ Implement summarized or partial context for token efficiency If you’d like, I can show a short example of a summarized handoff structure or how to call
copy()
with specific filters. Which would help you more? Sources: Agents and handoffs | LiveKit docs | Agent-assisted warm transfer | LiveKit docs | Workflows | LiveKit docs
i
Does it help with latency?
t
Short answer: context preservation can affect latency both ways — it can increase latency if you pass large histories, but LiveKit provides controls and patterns to keep handoffs fast. How it impacts latency • Passing full
chat_ctx
or large transcripts increases tokens sent to the model and raises request/response time. • Passing minimal, structured context (summaries, selected fields, or keys) keeps payloads small and reduces latency. • Fetching history from
session.history
on demand can add a small lookup cost but avoids sending unnecessary tokens to the model. Ways to optimize latency with LiveKit • Send summaries or structured context instead of whole transcripts. • Use
chat_ctx.copy()
with filters (
exclude_empty_message
,
exclude_instructions
,
exclude_function_call
) to trim what’s forwarded. • Store long histories externally and pass only relevant slices or references during handoffs. • Keep agents stateless and lightweight for quick triage; escalate to larger models only when needed. • Prune or compress history when token limits approach. If you want, I can suggest a specific handoff pattern (code example) tailored to your expected conversation length and latency targets. Which scenario should I model?