how to switch livekit agent at runtime?
# ask-ai
t
how to switch livekit agent at runtime?
t
Thanks for reaching out, sergey. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
LiveKit supports switching agents at runtime with several methods, depending on your use case: • Update Agent Directly: Use
update_agent(new_agent)
on your
AgentSession
to replace the agent and maintain session state. • Function Tools/Handoffs: Design function tools on your agent that return a different agent instance; this triggers an automatic agent handoff within the session. • Preserved Context: Session context and history are preserved during agent switches, allowing each agent to have unique configurations (TTS, LLM, plugins, etc.). You can also dynamically update agent instructions and configurations as needed. If you need specific code examples or have a particular workflow in mind, please share more details. Sources: Workflows | LiveKit Docs | examples/voice_agents/toggle_io.py | complex-agents/medical_office_triage/triage.py
t
why
update_agent
can not work?
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!