melodic-zoo-29246
07/13/2025, 2:32 AMtall-airline-16756
07/13/2025, 2:32 AMtall-airline-16756
07/13/2025, 2:35 AMAgent
instance from a tool function. This shifts conversation control to the new agent within the active session.
• AgentSession Management: Handoffs use the update_agent
method on the AgentSession
, switching to another agent as needed. Example:
session.update_agent(SecondAgent(chat_ctx=session.chat_ctx))
• Function Tool Integration: With RealtimeModel, handoff logic is implemented inside a tool:
@function_tool()
async def transfer_to_specialist(self):
"""Transfer to specialist when complex issue detected"""
return SpecialistAgent(chat_ctx=self.session.chat_ctx)
• Preserving Context: To maintain conversation history, pass chat_ctx
from the current session to the new agent at handoff.
• Session Usage: RealtimeModel instances are used directly in AgentSession
, supporting both standard text-based and real-time workflows, including agent handoff mechanics via tools.
Other features such as user data preservation and logic-based conditional handoffs are managed similarly to traditional LLM workflows. RealtimeModel’s built-in turn detection may impact the precise handoff timing, but not the workflow steps.
For further architectural or code integration examples, let me know your specific use case or scenario details—comprehensive handoff workflows and advanced patterns are available for multiple-agent handoff and SIP/call transfer integration if needed.
Sources: complex-agents/medical_office_triage/README.md | Agents 0.x migration guide | LiveKit Docs | Workflows | LiveKit Docs | Tool definition and use | LiveKit Docs | examples/avatar_agents/hedra/agent_worker.py | LLM Integrations | livekit/livekit_composite | DeepWiki