This example has a "transfer between agents" code,...
# ask-ai
r
This example has a "transfer between agents" code, but not implemented on front-end side. Is there an example to switch the agents during a user session? https://github.com/livekit/agents/blob/main/examples/voice_agents/langfuse_trace.py
t
Thanks for reaching out, Ivan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
If you'd like to switch agents during a user session, you can easily do so using the
AgentSession.update_agent()
method. This handy feature lets you smoothly hand off between agents while keeping the session context intact. Here are a few examples to guide you: • Long or Short Agent: You can switch between agents with different speaking styles using a function tool. For example, the
ShortAgent
can call
self.session.update_agent(LongAgent())
to switch over to
LongAgent
. • Personal Shopper: Depending on what the user needs—whether it's sales, returns, or triage—you can transfer control between agents. The
_transfer_to_agent
method helps update the session with the new agent seamlessly. • TTS Provider Comparison: If you want to switch between Text-to-Speech providers like Rime or ElevenLabs during a session, each provider has its own agent class, and users can request to switch as needed. If you want to dive deeper and see detailed examples, feel free to check out the python-agents-examples repository on GitHub. It’s a great resource to help you get started! Sources: Workflows | LiveKit Docs | pipeline-tts/changing_language/README.md