How can I prevent user input from interrupting my ...
# ask-ai
i
How can I prevent user input from interrupting my multimodal agent?
t
Thanks for reaching out, Matthew. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To prevent user input from interrupting your multimodal agent, you can set the
allow_interruptions
property of the speech object to
False
. This ensures that the system will ignore user input while the agent is speaking. For example:
Copy code
if not self._playing_speech.allow_interruptions:
    should_ignore_input = True
    logger.debug(
        "skipping validation, agent is speaking and does not allow interruptions",
        extra={"speech_id": self._playing_speech.id},
    )
When interruptions are not allowed, the system sets
should_ignore_input
to
True
, clears any transcribed text from the user, and returns without processing the input. Sources: livekit.agents.pipeline.pipeline_agent API documentation
i
Does this work for the realtime model?
t
Yes, the
allow_interruptions
property works for the realtime model as well. It is a boolean parameter that determines whether the user is allowed to interrupt the assistant during its operation. Sources: VPAOptions | LiveKit Agents
i
Are there other options to set the length of input before it is considered an interruption and stops the ai?
t
Yes, there are additional options to control when input is considered an interruption: • `interruptMinWords`: This parameter sets the minimum number of words that need to be transcribed for an interruption to be considered intentional. Note that setting this value may increase latency. • `interruptSpeechDuration`: This parameter defines the minimum duration of speech (detected by Voice Activity Detection) required to consider the interruption intentional. You can configure these parameters to fine-tune how interruptions are handled by your multimodal agent. Sources: VPAOptions | LiveKit Agents | VoicePipelineAgent | LiveKit Docs