I want to update dynamically during a call the min...
# ask-ai
c
I want to update dynamically during a call the min_interruption_words parameter. Is this possible?
t
Thanks for reaching out, Yousri. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — regarding your question about updating
min_interruption_words
during a call: Yes — you can update
min_interruption_words
at runtime. Update the session's voice/agent options using
update_options
on the `AgentSession`; changes take effect for subsequent interactions without restarting the session. Example (Python):
Copy code
session.update_options(min_interruption_words=2)
Would you like the equivalent snippet for Node.js or details on when the new value takes effect during an active turn? Sources: Turns overview | LiveKit docs | Agents (Node.js) | livekit/livekit_composite | DeepWiki
c
Are you sure about this? Looks like the only paramteters that can be updated are min_endpointing_delay, max_endpointing_delay and turn detection
t
Thanks — good catch. You're correct:
min_interruption_words
cannot be changed at runtime
. It is configured when the session is created and is not exposed via
update_options()
. You can dynamically update these options during a call: •
min_endpointing_delay
•
max_endpointing_delay
•
turn_detection
•
tool_choice
If you need dynamic interruption behavior, would you like help with alternatives (for example, adjusting endpointing delays or using
turn_detection
logic), or a code snippet showing where to set
min_interruption_words
at session creation? Sources: Agents (Python) | livekit/livekit_composite | DeepWiki | Agents (Node.js) | livekit/livekit_composite | DeepWiki | Turns overview | LiveKit docs
c
No, I want to update min_interruption_words dynamically. Can you write the python snippet to do that
t
Thanks — I hear you want to change
min_interruption_words
during an active call and asked for a Python snippet. I can’t provide a runtime update snippet because
min_interruption_words
cannot be changed dynamically — it must be set when the
AgentSession
is created. Two alternatives I can help with: • Show the Python snippet to set
min_interruption_words
at session creation. • Implement a runtime workaround (adjust
min_endpointing_delay
/
max_endpointing_delay
or toggle
turn_detection
, or restart the session with the new value) and provide the exact code for that. Which option would you like me to show?
c
Neitther of that. Inhreit from AgentSession to override update_options() method and add the min_interruption_words argument
t
Thanks — you're asking for a concrete Python example that subclasses
AgentSession
and overrides
update_options()
to accept and apply
min_interruption_words
. I can provide that example and note risks. Below is a concise subclass pattern you can adapt. It: • Adds
min_interruption_words
to
update_options()
• Stores the new value on the session instance • Ensures future interruption checks read the updated value Warning: this is a customization beyond the public runtime options and may be unsupported by the core library (it can break with upstream changes). Test thoroughly.
Copy code
# Example: subclass AgentSession to add runtime-updatable min_interruption_words
from livekit.agents.voice import AgentSession

class CustomAgentSession(AgentSession):
    def __init__(self, *args, min_interruption_words: int = None, **kwargs):
        super().__init__(*args, **kwargs)
        # initial value (may be None)
        self._min_interruption_words = min_interruption_words

    # expose a property for safe access
    @property
    def min_interruption_words(self):
        return self._min_interruption_words

    # override update_options to accept the extra parameter
    def update_options(self, *args, min_interruption_words: int = None, **kwargs):
        """
        Preserve existing behavior by calling the base implementation for known options,
        and handle min_interruption_words locally.
        """
        # First, call base class to handle supported runtime options
        super().update_options(*args, **kwargs)

        # Then handle our custom option
        if min_interruption_words is not None:
            # validate if needed
            if not isinstance(min_interruption_words, int) or min_interruption_words < 0:
                raise ValueError("min_interruption_words must be a non-negative integer")
            self._min_interruption_words = min_interruption_words

            # If interruption logic is implemented elsewhere in the session/agent,
            # ensure it reads `self.min_interruption_words` at evaluation time.
            # If any cached thresholds exist, update them here.
Notes on integration: • Ensure all places that decide interruption use
self.min_interruption_words
(not a constructor-only value). If the core library uses an internal, immutable config object, you may need to replace or patch that object where the checks occur. • If interruption checks are performed in another component (e.g., a separate detector instance), provide that component access to
session.min_interruption_words
or update its configuration when you set the value. • Keep this subclass local to your codebase and add tests to detect future incompatibilities with upstream changes. If you want, I can: • Produce a version that patches a specific detector class or shows where to wire
self.min_interruption_words
into the interruption-checking logic in your codebase. • Provide a Node.js equivalent. Which would you prefer?