how to swtich agent session from frontend
# ask-ai
b
how to swtich agent session from frontend
t
Thanks for reaching out, RikuKomiya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just a quick heads-up: switching an agent session in LiveKit can’t be done straight from the frontend. Instead, it’s something you’ll handle on the server side using the
update_agent
method of the
AgentSession
class. But don’t worry—the frontend can still ask the server to make that switch by calling a server-side function tool based on what the user wants. Here’s a simple way to set up agent switching: 1. Define a few different agent classes, each with its own setup. 2. Create server-side function tools that either call
update_agent()
or provide a new agent instance. 3. From the frontend, trigger these tools whenever the user takes an action or a certain condition is met. 4. The framework will smoothly handle swapping agents while keeping the conversation flow intact. If you’d like, I’m happy to share more details or examples to help you get this up and running! Sources: Workflows | LiveKit Docs | avatars/hedra/education_avatar/education-frontend/components/session-view.t... | agents/src/voice/agent_session.ts