clean-doctor-99713
09/26/2025, 2:49 PMtall-airline-16756
09/26/2025, 2:49 PMtall-airline-16756
09/26/2025, 2:50 PMclean-doctor-99713
09/26/2025, 2:51 PMtall-airline-16756
09/26/2025, 2:52 PM@function_tool()
async def transfer_to_billing(self, context: RunContext):
return BillingAgent(), "Transferring to billing specialist"
• In Node.js: You can use llm.handoff() to specify the new agent along with an optional message. Here's how it looks:
const myTool = llm.tool({
execute: async (_, { ctx }) => {
return llm.handoff({
agent: new SpecializedAgent(),
returns: 'Transferring to specialist team'
});
}
});
If anything feels unclear or you’d like a hand with setting this up, please don’t hesitate to ask. I’m here to help!
Sources: Workflows | LiveKit Docs | Docs::Agents | agents/src/llm/tool_context.tsclean-doctor-99713
09/26/2025, 2:52 PMtall-airline-16756
09/26/2025, 2:54 PMmin_interruption_duration (the minimum speech time) and min_interruption_words (the minimum number of words) to help avoid false alarms.
• Manual Interruption: If needed, interruptions can also be triggered manually using session.interrupt(), even when automatic interruptions are turned off.
• Context Management: When an interruption happens, the conversation history is trimmed to show only what the user has heard, so the flow stays clear and consistent.
• Avatar Integration: For AI avatars, LiveKit instantly notifies the avatar server to stop any pre-generated animations and switch to a listening mode.
All these features work together to make sure interruptions feel natural and don’t disrupt the experience. If you’d like, I’m here to help you set up these settings or walk you through handling interruptions—just let me know!
Sources: agents/src/voice/agent_activity.ts | Bringing AI avatars to voice agents | VoicePipelineAgent | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py | Docs::Agentsclean-doctor-99713
09/26/2025, 4:49 PMtall-airline-16756
09/26/2025, 4:50 PMallow_interruptions=False in the agent's configuration to make sure all responses run smoothly without interruptions. For example:
agent = Agent(allow_interruptions=False)
• Disable Interruptions for Specific Functions: Inside a tool, you can use RunContext.disallow_interruptions() to make sure important functions finish without any hiccups. For example:
@function_tool
async def critical_function(run_ctx: RunContext):
run_ctx.disallow_interruptions()
# Perform critical task
return "Task completed."
• Disable Interruptions for Specific Speech: When you call session.say() or session.generate_reply(), just pass allow_interruptions=False to keep the message uninterrupted. For example:
session.say("Processing your request...", allow_interruptions=False)
These approaches are here to help your agent complete its tasks or messages without being cut off. If you’d like, I’m happy to walk you through setting this up!
Sources: basics/uninterruptable/uninterruptable.py | agents/src/voice/agent_activity.ts | livekit-agents/livekit/agents/voice/agent_session.py | Turn detection and interruptions | LiveKit Docsclean-doctor-99713
09/26/2025, 5:48 PMRunContext.disallow_interruptions() to make sure important functions finish without any hiccups. For example:
• @function_tool
• async def critical_function(run_ctx: RunContext):
• run_ctx.disallow_interruptions()
• # Perform critical task
• return "Task completed."tall-airline-16756
09/26/2025, 5:49 PMallow_interruptions property of the SpeechHandle back to True. Here’s a little example to guide you:
# Inside a function tool
def my_function_tool(self, run_ctx: RunContext):
# Disallow interruptions
run_ctx.disallow_interruptions()
# Perform some task
await asyncio.sleep(2)
# Re-enable interruptions
run_ctx.speech_handle.allow_interruptions = True
Once you set allow_interruptions to True, the user will be able to interrupt the agent again. If you have any questions or need a hand with anything else, please don’t hesitate to ask—I’m here to help!
Sources: examples/voice_agents/long_running_function.pyclean-doctor-99713
09/26/2025, 5:51 PMtall-airline-16756
09/26/2025, 5:52 PMonEnter method for the next agent, you can simply set allow_interruptions=True when starting the speech. Here’s a little example to guide you:
async def on_enter(self):
self.session.generate_reply(
instructions="Welcome! How can I assist you?",
allow_interruptions=True
)
This way, the user will be able to interrupt the agent’s speech during this part. If you have any questions or need more help, just let me know—I’m here for you!
Sources: livekit-agents/livekit/agents/voice/speech_handle.py | Docs::Agents | basics/uninterruptable/uninterruptable.pyclean-doctor-99713
09/26/2025, 6:39 PMtall-airline-16756
09/26/2025, 6:40 PMclean-doctor-99713
09/26/2025, 6:40 PM