mysterious-noon-79219
11/20/2025, 12:50 PMtall-airline-16756
11/20/2025, 2:39 PMagent_false_interruption event to handle cases where interruptions turn out to be false alarms. For example:
async def on_false_interruption(event):
print(f"False interruption detected, resumed: {event.resumed}")
# Your custom hook logic here
# Register the event handler
session.on("agent_false_interruption", on_false_interruption)
• Tool Execution Interruption Hooks: Another way is to monitor interruptions during tool execution by checking run_ctx.speech_handle.interrupted and then defining what you'd like to happen next:
async def my_tool(self, run_ctx):
try:
await some_async_operation()
if run_ctx.speech_handle.interrupted:
await self.handle_tool_interruption()
except asyncio.CancelledError:
if run_ctx.speech_handle.interrupted:
await self.cleanup_after_interruption()
• Programmatic Interruption Hooks: You can also create hooks that respond to programmatic interruptions like this:
# Trigger interruption and execute custom logic
handle = session.say("Hello world")
await self.before_interruption_hook()
handle.interrupt()
await self.after_interruption_hook()
If you have any questions or want to dive deeper into any of these methods, just let me know. I'm here to support you every step of the way!
Sources: Turn detection and interruptions | LiveKit Docs | livekit-agents/livekit/agents/voice/events.py | Tool definition and use | LiveKit docsmysterious-noon-79219
11/20/2025, 5:48 PMtall-airline-16756
11/20/2025, 5:49 PMuser_input_transcribed event in the Python SDK. This event triggers whenever the system detects and transcribes user speech, making it your go-to tool for identifying and responding to those interruptions.
Method 1: Using user_input_transcribed Event
This event fires for both interim (partial) and final (complete) transcriptions. By listening to interim transcripts, you can respond as soon as the user starts speaking, which is really helpful:
async def handle_interruption():
session.say("Sorry, can I pause you there?", allow_interruptions=False)
await session.generate_reply(allow_interruptions=False)
@session.on("user_input_transcribed")
def on_transcript(transcript):
if not transcript.is_final: # Process interim speech
if "specific condition met":
asyncio.create_task(handle_interruption())
Method 2: Overriding stt_node
If you want more fine-grained control, you can override the stt_node method in a custom agent class. This gives you direct access to the transcription pipeline, letting you handle user input in real-time:
async def stt_node(self, text: AsyncIterable[str], model_settings=None):
async for event in parent_stream:
if hasattr(event, 'type') and str(event.type) == "SpeechEventType.FINAL_TRANSCRIPT":
# Custom logic for user interruptions
await self.session.say("Let me stop you there.")
At the moment, there isn't a dedicated on_user_interruption event, but if this is something important for your project, contributing to the development could be a wonderful way to help improve it. Please don’t hesitate to reach out if you’d like any more guidance or support—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | basics/uninterruptable.py | Turn detection and interruptions | LiveKit Docsmysterious-noon-79219
11/20/2025, 5:51 PMtall-airline-16756
11/20/2025, 5:52 PM{ "interrupted": true } whenever it detects a user interruption.
2. Programmatic Interruption:
If you want to control interruptions yourself, you can use the session.interrupt() method to programmatically interrupt the agent’s speech:
# Interrupt the agent
session.interrupt()
3. Configuration Options:
• Make sure to set allow_interruptions=True in your session configuration to enable this feature.
• You can also tweak min_interruption_duration to specify the minimum speech length needed to trigger an interruption.
4. Handling Interruptions in Tools:
For tools that run longer, you can check the run_ctx.speech_handle.interrupted flag to detect interruptions and run any custom cleanup logic you might need.
If anything feels unclear or you’d like a hand implementing these strategies, please don’t hesitate to ask—I’m here to help!
Sources: Turn detection and interruptions | LiveKit Docs | livekit-plugins/livekit-plugins-ultravox/livekit/plugins/ultravox/realtime/... | Tool definition and use | LiveKit docsmysterious-noon-79219
11/20/2025, 5:54 PM