agents icon indicating copy to clipboard operation
agents copied to clipboard

`min_interruption_duration` seems to be ignored over `min_interruption_words`

Open luiz00martins opened this issue 1 year ago β€’ 26 comments

Description

Using min_interruption_duration seems to be ignored over min_interruption_words , when these are set up in the settings:

        session = AgentSession[InboundCallData](
            preemptive_generation=preemptive_generation, # False
            stt=stt_engine,  # Amazon Transcribe
            llm=llm_engine,  # OpenAI
            tts=tts_engine,  # Elevenlabs
            vad=session_vad, # Silero VAD
            turn_detection=turn_detection, # "vad"
            userdata=call_data,
            mcp_servers=mcp_servers,
            user_away_timeout=user_away_timeout,
            allow_interruptions=allow_interruptions, # True
            min_interruption_duration=min_interruption_duration, # Tested as described below
            min_interruption_words=min_interruption_words, # Tested as described below
            min_endpointing_delay=min_endpointing_delay,
            max_endpointing_delay=max_endpointing_delay,
        )

Here's the behavior I'm getting:

  • If I keep the defaults (min_interruption_duration = 0.5 and min_interruption_words = 0), it behaves as expected, with the user interrupting the agent with short utterances.
  • If I increase the min_interruption_duration to 10.0, but keep the min_interruption_words at default (0), the behavior doesn't change. The model is still interrupted after ~1 second.
    • One important note about this: I've read https://github.com/livekit/agents/issues/2197, and @longcw mentions that "min_interruption_duration won't block STT event to interrupt the agent". However, don't think it's an STT event that is blocking the agent. See the section "Why I suspect the STT is not interrupting the agent" below.
  • If I keep the default the min_interruption_duration to 0.5, but increase min_interruption_words to 50 (0), the model will only be interrupted after a very long phrase (I presume, after 50 words). Talking for more than 0.5 seconds will not interrupt it.
  • If I increase both to high values, the model is triggered

That is, the min_interruption_duration seems to have no effect in the behavior of the model, and only setting min_interruption_words higher or lower seems to make a difference on the tolerance of the model for interruption from the user.

Why I suspect the STT is not interrupting the agent

If you say a small utterance, as expected, an STT event will be triggered, and the agent will be interrupted.

However, even if you keep talking with no breathing (giving no breaks for the STT to get the transcript), the agent will still be interrupted after roughly 1 second.

We have an stt_node set up, and can confirm though the logs that it's not triggered until the utterance finishes. The agent however, will be interrupted way before that. That is, if you talk non-stop for 5 seconds, the agent will still be interrupted after just the first second (even though the stt_node is only triggered at the end of the 5th second).

Therefore, I suspect it's not the case that the model is being interrupted by an STT event.

Environment

  • OS: Windows 11
  • Livekit Version: 1.2.11

luiz00martins avatar Sep 26 '25 14:09 luiz00martins

As an addendum, after some talk with Devin (from livekit's DeepWiki, see conversation at https://deepwiki.com/search/see-this-issue-description-usi_f0eebdf1-72aa-486e-9990-a4d9e2e5414a), here's his statements:


Why STT Causes "Immediate" Interruption

Even though the final STT transcript only arrives after the user finishes speaking, interim STT transcripts are generated during speech and can trigger interruption immediately: 3

When min_interruption_words = 0, any interim transcript text (even a single word) will bypass the word count check and cause interruption.

[...]

Interaction Logic - AND Condition, Not OR

The key finding is that these parameters work together as an AND condition - both thresholds must be satisfied for an interruption to occur, not just one or the other.

Duration Check First

When VAD (Voice Activity Detection) processes audio, it first checks if the speech duration meets the minimum threshold: 3

Word Count Check Second

If the duration threshold passes, the system then calls _interrupt_by_audio_activity(), which performs an additional check for word count when STT is enabled and min_interruption_words > 0: 4

If the current transcript doesn't contain enough words, the method returns early, effectively blocking the interruption even though the duration requirement was met.

[...]

Why Single Word Causes Immediate Interruption

When the STT-based pathway triggers interruption, it calls the same _interrupt_by_audio_activity() method, which then checks the min_interruption_words constraint 3 . Since you've set min_interruption_words to 1, this check passes as soon as there's one word in the transcript.

The critical insight is that the STT interim transcript pathway bypasses the duration check entirely. The 30.0 second min_interruption_duration only applies to the VAD-based interruption pathway, not to STT-triggered interruptions.

[..]


These two together (the fact the logic between the two seems to with in an "AND" fashion, and the fact that 'interim' transcriptions are enough to trigger the STT word interruption, bypassing duration), means that the min_interruption_words will always end up overwriting the min_interruption_duration. More specifically:

  • If you put the min_interruption_words high, it'll always be the one triggering the interruption, as min_interruption_duration will always wait for it.
  • If you put the min_interruption_words low, it'll always be the one triggering the interruption, as the interim interruption will be immediately triggered after hitting the word minimum, ignoring the min_interruption_duration.

luiz00martins avatar Sep 29 '25 22:09 luiz00martins

If I keep the default the min_interruption_duration to 0.5, but increase min_interruption_words to 50 (0), the model will only be interrupted after a very long phrase (I presume, after 50 words). Talking for more than 0.5 seconds will not interrupt it.

this is expected, interruption needs min_interruption_duration AND min_interruption_words BOTH reached the criteria.

If I increase the min_interruption_duration to 10.0, but keep the min_interruption_words at default (0), the behavior doesn't change. The model is still interrupted after ~1 second.

the agent will ALWAYS be interrupted by final user transcription from STT after the min_endpointing_delay (default 0.5s), ~no matter what is min_interruption_duration and min_interruption_words. It's to start a generation after STT returns the final transcript.~

CORRECTION: actually min_interruption_words is check for final transcription interruption as well, see https://github.com/livekit/agents/issues/3515#issuecomment-3349672151

fyi, min_interruption_words will count the interim transcription, ~that's the difference to the interruption by final user transcription.~

longcw avatar Sep 30 '25 00:09 longcw

close since it's not a bug. feel free to reopen or create a new one for your expected interruption behavior.

longcw avatar Sep 30 '25 00:09 longcw

This did not answer my issue at all, @longcw .

this is expected, interruption needs min_interruption_duration AND min_interruption_words BOTH reached the criteria.

Yes, I understood that. I explicitly stated it in my comment.

the agent will ALWAYS be interrupted by final user transcription from STT after the min_endpointing_delay (default ~0.5s), no matter what is min_interruption_duration and min_interruption_words.

Endpointing was not reached. The agent is interrupted even while the user is speaking. As described by min_endpointing_delay: "Minimum time-in-seconds the agent must wait after a potential end-of-utterance signal". The interruption happens even if I didn't finish my utterance. Speaking non-stop for 10 seconds, will still stop the agent at second 1. If min_endpointing_delay is triggering that, its description is wrong (or the behavior is wrong), as end-of-utterance wasn't reached.

fyi, min_interruption_words will count the interim transcription, that's the difference to the interruption by final user transcription.

Yes, I understood that. I explicitly stated it in my comment.

However, that conflicts with your first phrase:

this is expected, interruption needs min_interruption_duration AND min_interruption_words BOTH reached the criteria.

This is not true. At least according to my test. Setting min_interruption_duration to 30.0, and min_interruption_words to 1 will stop the agent after 1 word, regardless of whether it took you 30 seconds to say it.

I understand the behavior you described. It is not the behavior I'm getting. If what you said is the expected behavior, this is a bug.

luiz00martins avatar Sep 30 '25 01:09 luiz00martins

Setting min_interruption_duration to 30.0, and min_interruption_words to 1 will stop the agent after 1 word, regardless of whether it took you 30 seconds to say it.

~check my comment here "the agent will ALWAYS be interrupted by final user transcription from STT."~

~If the STT returns a final transcript, no matter how long it is, it will interrupt the agent and start a new response after the min_endpointing_delay.~

longcw avatar Sep 30 '25 01:09 longcw

~I guess the misunderstanding is, except min_interruption_duration and min_interruption_words, the final transcription can also interrupt the agent.~

the first two options are for interruption before the user turn end; and the final transcription means the end of the user turn, ~so the agent will always be interrupted and starts a new reply to the user input.~

CORRECTION: actually min_interruption_words is used for final transcription, see https://github.com/livekit/agents/issues/3515#issuecomment-3349672151

longcw avatar Sep 30 '25 01:09 longcw

I don't think that's correct also. Here's another experiment:

Set the min_interruption_words to a high value of 50, and min_interruption_duration to whatever (it won't matter for this experiment).

If the STT returns a final transcript, no matter how long it is, it will interrupt the agent and start a new response after the min_endpointing_delay.

If I'm understanding what you're saying, we would expect that, regardless of how high min_interruption_words is, the agent will be interrupted if we just utter a short phrase, and stay silent (so a final STT transcript can be triggered).

However, that doesn't happen. The agent won't be interrupted until you reach the 50 words cap (regardless of whether it's interim or in the final phrase).

That is, I can see a transcript event was triggered in my terminal (DEBUG livekit.agents - received user transcript), but the agent will not be interrupted.

luiz00martins avatar Sep 30 '25 01:09 luiz00martins

do you have EOU (turn detection) model enabled? if so, it will detect if the user turn completed and wait for max_endpointing_delay if the model thinks the user transcription is imcompeleted.

and do you see any EOUMetrics in the log, there you will see the end_of_utterance_delay of this turn? you can log it with https://github.com/livekit/agents/blob/[email protected]/examples/voice_agents/basic_agent.py#L97-L100

longcw avatar Sep 30 '25 01:09 longcw

Nop, not using EOU.

Here's the result of the log (logged similar to the example linked):

2025-09-29 22:56:11,915 - INFO session-builder - Usage: UsageSummary(llm_prompt_tokens=0, llm_prompt_cached_tokens=0, llm_input_audio_tokens=0, llm_completion_tokens=0, llm_output_audio_tokens=0, tts_characters_count=401, tts_audio_duration=19.06938775510208, stt_audio_duration=0.0)

luiz00martins avatar Sep 30 '25 01:09 luiz00martins

I mean the logs like

2025-09-30 09:57:48,377 - INFO livekit.agents - EOU metrics {"room": "room-x3AJ-5nuR", "model_name": "multilingual", "model_provider": "Livekit", "end_of_utterance_delay": 0.92, "transcription_delay": 0.88, "pid": 2275096, "job_id": "AJ_ZFttmF3TXMFT"}

and let me clarify it again: the final user transcription is a trigger for end of user turn, waiting a timeout between min_endpointing_delay and max_endpointing_delay based on the EOU model prediction, and the end of user turn will always interrupt the agent.

the min_interruption_duration/min_interruption_words and the end of user turn are two different interruption paths and are not affecting each other, the first one for interruption while user is still speaking, the later is for after user turn and response generation.

If you think the final transcription didn't trigger an end of user turn, then it's a different issue that needs more logs to investigate.

longcw avatar Sep 30 '25 01:09 longcw

If that's not the case, sounds like a bug and I'll take a look.

longcw avatar Sep 30 '25 02:09 longcw

Okay I think you are right, just checked the code, min_interruption_duration is not affecting the end of turn interruption, but min_interruption_words is also used as a criteria for it. So if min_interruption_words is set, the end of turn will also wait for the user transcriptions > min_interruption_words before triggering.

If this is not expected, maybe we can separate the min_interruption_words into two: one for interruption during speaking, one for end of user turn.

longcw avatar Sep 30 '25 02:09 longcw

No, I don't see any EOU metrics at all. I presume it's because EOU is not active for my agent.

My issue is double pronged (it seems). The interruptions are not behaving in any way the way it's being described. And we're going back-and-forth, because we're bouncing between very different issues. You're free to separate them into different GitHub issues, if you want.

Here's both of them, separated:


The agent does not care about min_interruption_duration

To Reproduce

  • Set min_interruption_duration to 30.0
  • Set min_interruption_words to 1
  • Speak a very long phrase, uninterrupted (don't breathe or stop). Try this one:

β€œOn offering to help the blind man, the man who then stole his car, had not, at that precise moment, had any evil intention, quite the contrary, what he did was nothing more than obey those feelings of generosity and altruism which, as everyone knows, are the two best traits of human nature and to be found in much more hardened criminals than this one, a simple car-thief without any hope of advancing in his profession, exploited by the real owners of this enterprise, for it is they who take advantage of the needs of the poor.”

Expected Behavior

The agent will wait till the end of the passage, or 30 seconds, before getting interrupted.

Current Behavior

The agent will get interrupted after the first word.

The agent does not care about the last utterance

  • Set min_interruption_words to 100
  • Speak a short phrase like:

I love the taste of apples.

Expected Behavior

The agent will get interrupted by the short phrase.

Current Behavior

The agent will not get interrupted. Only if you continue to reach 100 words.

luiz00martins avatar Sep 30 '25 02:09 luiz00martins

The first issue is the one I actually opened this issue for. Please, try to replicate it. If you are able to, please, reopen this issue.

I understand the expected behavior. That behavior is not happening.

luiz00martins avatar Sep 30 '25 02:09 luiz00martins

I think both the two behaviors are expected based on the current code base as the discussion above (https://github.com/livekit/agents/issues/3515#issuecomment-3349672151):

  1. min_interruption_duration is not considered for end of turn interruption, min_interruption_words is, so when min_interruption_words is 1, the agent will be interrupted by the a single word.
  2. when min_interruption_words is 100, it will need that many words to trigger the end of turn.

I actually don't know what's your expected behavior now.

longcw avatar Sep 30 '25 02:09 longcw

@longcw , you're contradicting yourself:

this is expected, interruption needs min_interruption_duration AND min_interruption_words BOTH reached the criteria.

min_interruption_duration is not considered for end of turn interruption, min_interruption_words is, so when min_interruption_words is 1, the agent will be interrupted by the a single word

Are both necessary, or just one?

luiz00martins avatar Sep 30 '25 02:09 luiz00martins

this comment https://github.com/livekit/agents/issues/3515#issuecomment-3349672151 is the final and correct one, I didn't realize the min_interruption_words is also used for end of turn.

longcw avatar Sep 30 '25 02:09 longcw

Alright, I understand. So, then, there's a misalignment on expected behavior and actual behavior, right?

Expected: Interruption needs min_interruption_duration and min_interruption_words both to reach the criteria. Actual: min_interruption_duration is not considered for end of turn interruption

So this constitutes a bug, right?

luiz00martins avatar Sep 30 '25 02:09 luiz00martins

Alright, I understand. So, then, there's a misalignment on expected behavior and actual behavior, right?

Expected: Interruption needs min_interruption_duration and min_interruption_words both to reach the criteria. Actual: min_interruption_duration is not considered for end of turn interruption

So this constitutes a bug, right?

Yes this is exactly what happens. I think the question is do we want to check min_interruption_duration for end of turn, personally I think it's too risky that the agent will be unresponsive if the VAD has a false negative or splits user speeches into multiple smaller chunks (which is very likely).

longcw avatar Sep 30 '25 03:09 longcw

Got it. I think your suggestion of having two separate configs for the words might be the best option.

If I'm understanding correctly, if we have a new setting, say min_eot_interruption_words, and I had:

  • min_eot_interruption_words = 10000
  • min_interruption_words = 1
  • min_interruption_duration = 30.0

Then the model would wait the 30 seconds before accepting the interruption?

luiz00martins avatar Sep 30 '25 03:09 luiz00martins