many-forest-60185
11/17/2025, 5:56 AMtall-airline-16756
11/17/2025, 5:57 AMtall-airline-16756
11/17/2025, 5:57 AMAgent instance along with an optional result message. For example:
@function_tool()
async def information_gathered(self, context: RunContext, name: str, location: str):
context.userdata.name = name
context.userdata.location = location
return StoryAgent(name, location), "Let's start the story!"
• Node.js: You can use llm.handoff() to return the new agent and an optional message. Here’s a simple example:
return llm.handoff({
agent: new SomeAgent(),
returns: "Transferring the user now"
});
Here are a few key things to keep in mind:
• The conversation history is preserved and accessible in session.history during handoffs, so nothing gets lost.
• You can easily pass user data or context between agents using context.userdata or through constructor parameters.
• Handoffs are triggered programmatically via tools, but the LLM decides the best moment to invoke them based on how the conversation flows.
If you’d like to explore more, the warm transfer example in the LiveKit repository is a great resource to check out.
Sources: Tool definition and use | LiveKit docs | Workflows | LiveKit docs | README.md | README.md | Testing and evaluation | LiveKit Docs