damp-whale-18867
09/07/2025, 1:03 PMtall-airline-16756
09/07/2025, 1:03 PMtall-airline-16756
09/07/2025, 1:04 PMAgent class, where you can set up instructions, speech-to-text (STT), text-to-speech (TTS), and more.
• Agent Handoff: You can switch between agents easily using session.update_agent(new_agent) or even do it dynamically from a tool call.
• State Management: Keep things consistent by passing data between agents with session.state or session.userdata, so your workflow progresses just the way you expect.
• Declarative Workflow Orchestration: Set up a flow dictionary that links stages to agents and defines what comes next, giving you a clear, structured pipeline.
• Tasks (Experimental): Tasks let you temporarily take control of a session for specific goals, like transcribing audio or checking input.
If you want to dive deeper, check out the Workflows Documentation and the Declarative Flow Example—they have some great examples to guide you.
This setup is perfect for making sure your deterministic business processes, like customer support or automated surveys, run reliably every time.
Sources: Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Building the all-in-one platform for voice AI agents | Building the all-in-one platform for voice AI agents | Workflows | LiveKit Docs | Workflows | LiveKit Docsdamp-whale-18867
09/07/2025, 1:56 PMneed to create an agent that orchestrates different tasks.
tall-airline-16756
09/07/2025, 1:56 PMAgent class to build agents, each tailored with specific instructions and tools for their unique role.
• Orchestrate Agent Handoffs: Use llm.handoff() inside a tool call to smoothly pass control between agents whenever needed.
• Use Tasks: Try out tasks for short-term jobs like transcription or sentiment analysis (it’s an experimental feature, so feel free to explore).
• Share State: Keep things connected by using userData to save and share session info across agents, ensuring everything flows seamlessly.
• Initialize the Session: Kick things off with an entry agent via session.start(), then call on other agents as the session evolves.
This setup is great for managing step-by-step interactions, like customer service journeys or complex workflows. If you want me to walk you through any part or share some examples, just let me know—I’m here to help!
Sources: examples/src/restaurant_agent.ts | Workflows | LiveKit Docs | Workflows | LiveKit Docsdamp-whale-18867
09/07/2025, 1:58 PMtall-airline-16756
09/07/2025, 1:59 PMdamp-whale-18867
09/07/2025, 2:01 PMtall-airline-16756
09/07/2025, 2:01 PMdamp-whale-18867
09/07/2025, 2:02 PMtall-airline-16756
09/07/2025, 2:03 PMAgent class to build agents tailored for specific roles or tasks. You can use tools to set up transitions or actions.
• Orchestrate Tasks: Think of Tasks as short-term helpers for things like filling out forms or gathering data. Agents can call these tasks and get results once they’re done.
• Agent Handoffs: Easily switch control between agents by using session.update_agent() or by returning a new agent instance from a tool call.
• Share State: Keep everything connected by passing shared context (like chat_ctx) between agents so info isn’t lost during transitions.
• Start the Session: Kick things off by initializing the session with an entry agent via AgentSession, then call on tasks or other agents whenever you need.
If you want to see these steps in action, check out the Drive-thru Agent or the Restaurant Agent. And hey, if you have any questions or want a hand, just let me know—I’m here to help!
Sources: Building voice agents | LiveKit Docs | Deploying to custom environments | LiveKit Docs | Workflows | LiveKit Docsdamp-whale-18867
09/07/2025, 10:40 PMtall-airline-16756
09/07/2025, 10:41 PMdamp-whale-18867
09/07/2025, 10:42 PMdamp-whale-18867
09/07/2025, 10:42 PMdamp-whale-18867
09/07/2025, 10:43 PMtall-airline-16756
09/07/2025, 10:43 PMsession.userdata). Then, when you’re ready, just call session.update_agent() to switch back smoothly.
• Create a Tool to Return the Original Agent: You can set up a tool inside your current agent that sends you back to the original one. Here’s a quick example:
@function_tool()
async def return_to_original(self):
return "Returning to the main agent.", self.original_agent
• Keep Your Data Safe: Use session.userdata to store any shared info along with the original agent reference. This way, nothing gets lost when you switch back.
• Merge Chat History: When you pick up with the original agent again, use chat_ctx.merge() to blend the conversation history and keep everything feeling natural.
These tips should help you create smooth handoffs and keep the conversation flowing nicely. If you want me to walk you through any part or share more examples, just let me know—I’m here to help!
Sources: Tool definition and use | LiveKit Docs | examples/src/restaurant_agent.ts | livekit-agents/livekit/agents/voice/agent_session.py | Workflows | LiveKit Docstall-airline-16756
09/07/2025, 10:43 PMuserdata. This way, you won’t lose track of it.
• Hand Control Back: Once the current agent finishes its job, you can use a tool to return the saved orchestrator agent. For example:
@function_tool()
async def return_to_orchestrator(self, ctx):
orchestrator = ctx.userdata.orchestrator_agent
return "Returning to the orchestrator.", orchestrator
• Switch Agents Smoothly: If needed, use session.update_agent() to switch back to the orchestrator agent programmatically.
This way, the orchestrator gets control again and can keep things running smoothly. If you want me to walk you through it or share more examples, just let me know!