future-glass-56154
12/12/2025, 5:47 PMtall-airline-16756
12/12/2025, 5:47 PMtall-airline-16756
12/12/2025, 5:48 PMdisallow_interruptions. Below is a concise explanation and a practical example.
What it does
• Prevents user interruptions while a tool/function is executing critical or non‑interruptible work.
• Applies only for the duration of that tool's execution.
• Use sparingly for operations that must finish or cannot be safely rolled back.
Example (Python-style function tool)
@function_tool()
async def perform_search(context: RunContext, query: str) -> str:
# Prevent user from interrupting this critical operation
context.disallow_interruptions()
# Long-running or non-interruptible work
result = await long_running_search(query)
return result
When to use it
• Saving critical state, committing transactions, or performing external calls that must complete.
• Avoid using it for routine or short operations; provide status updates instead for long-running but interruptible tasks.
If you want, I can:
• Show an example with status updates before/after disallow_interruptions()
• Convert the example to your code style or language (Node/TS, etc.) Sources: External data and RAG | LiveKit Docsfuture-glass-56154
12/12/2025, 7:15 PMtall-airline-16756
12/12/2025, 7:15 PMallow_interruptions=False when a function tool calls session.say() or session.generate_reply(), and whether that requirement is related to the speech handle being updated.
Short answer:
• You only need to set allow_interruptions=False if you want that specific speech output to be uninterruptible by the user.
• This is a per-call setting on each speech invocation, not because the speech handle is updated.
Details:
• Each session.say() / session.generate_reply() call creates a new SpeechHandle and evaluates allow_interruptions for that handle.
• By default interruptions are allowed (allow_interruptions=True). Set False on the call when you want to prevent barge‑in for that segment (e.g., critical announcements).
• Even with allow_interruptions=False, you can still programmatically cancel via session.interrupt() or handle.interrupt().
If you want, I can:
• Show a short code example (Python or Node) demonstrating an uninterruptible session.say() followed by an interruptible one.
• Explain patterns for when to use disallow_interruptions() at the tool level vs allow_interruptions=False on speech calls. Sources: Turn detection and interruptions | LiveKit Docs | Agent speech and audio | LiveKit docsfuture-glass-56154
12/12/2025, 7:17 PMtall-airline-16756
12/12/2025, 7:17 PMallow_interruptions=False on session.say() if you want that specific speech to be uninterruptible. context.disallow_interruptions() and allow_interruptions control different things:
• context.disallow_interruptions() (called inside a function/tool) prevents the tool's execution from being interrupted by user input for the duration of the tool.
• session.say() / session.generate_reply() each create a new SpeechHandle and evaluate allow_interruptions per call. If you want the spoken output produced by that call to be uninterruptible by the user, call it with allow_interruptions=False.
So if your function calls context.disallow_interruptions() and then does session.say(), the tool is already protected from user interruptions while running, but the speech itself will still be interruptible unless you explicitly call session.say(..., allow_interruptions=False).future-glass-56154
12/12/2025, 7:21 PMtall-airline-16756
12/12/2025, 7:21 PMsession.interrupt(). Use it when you need to forcibly stop the agent's current speech or queued responses under program control. Key cases:
• To immediately stop speech in response to an external event (UI button, RPC, or signal) regardless of VAD or allow_interruptions.
• To implement custom turn-taking (push-to-talk, explicit user start) where you programmatically end the agent's turn before enabling user input.
• To cancel long-running work when the user or system indicates you should stop (e.g., cancel an HTTP request if handle.interrupted is set).
• To override an uninterruptible speech (allow_interruptions=False) when you must stop anyway.
Notes:
• You don't need session.interrupt() for normal user barge-in if VAD is enabled and allow_interruptions=True — the framework will interrupt automatically.
• session.interrupt() affects speech immediately and clears queued responses; tools should handle cleanup if interrupted.
If you want, I can show a short code example (TS or Python) demonstrating a frontend RPC triggering session.interrupt(). Which language do you prefer?
Sources: Turn detection and interruptions | LiveKit Docs | Agent speech and audio | LiveKit docs | Tool definition and use | LiveKit docsfuture-glass-56154
12/12/2025, 8:00 PMtall-airline-16756
12/12/2025, 8:00 PMsession.update_options(turn_detection="manual")
This correctly updates the session runtime config and disables automatic turn detection.
• Do not use:
self.turn_detection = "manual"
Direct assignment does not reconfigure the session internals and will not reliably disable turn detection.
Notes for irreversible work:
• After setting turn_detection="manual", no automatic user turns will be created; new turns only start if you explicitly call session.commit_user_turn() (or re-enable another mode).
• You can also stop audio capture with session.input.set_audio_enabled(False) for extra safety.
Would you like a short code snippet showing an irreversible action followed by disabling turn detection?
Sources: Agents (Python) | livekit/livekit_composite | DeepWiki | Turn detection and interruptions | LiveKit Docs