We recently changed the two setting MIN_INTERRUPTI...
# agents
g
We recently changed the two setting MIN_INTERRUPTION_WORDS to 2. the default is 1. We are on version 1.2.8. Immediately after flipping this from 1 to 2. We are experiencing an issue where the assistant is interrupting the caller before they are done speaking. We can reproduce this. To test, we recorded a few sentences and played it back to the assistant without any subjectivity or variation in the timing of spoken words. When we flip it to MIN_INTERRUPTION_WORDS=1 the assistant does not interrupt the caller. As soon as it is flipped to 2 the assistant will interrupt the caler. Does anyone know if MIN_INTERRUPTION_WORDS is somehow breaking turn-detection?
r
I just tested with this example that set the min to 3 and it seems fine to me: https://github.com/livekit/agents/blob/main/examples/voice_agents/speaker_id_multi_speaker.py
If you run that example do you get the same issue?
g
do you have a way to see the input and output
you wont hear the problem
the problem will be in the real-time transcript
this also causes the assistant to answer questions from the wrong question
r
So this is a transcript issue? Above it sounded like it interrupts the speaker
To test, we recorded a few sentences
What is the script you recorded?
Agent playground will show realtime transcript. What should I look for there?
g
0911.mp4
here is an example
so that is with MIN_INTERRUPTION_WORDS: 3
now im going to set it to 1 and play that audio back to the assistant
now here is MIN_INTERRUPTION_WORD set to 1. I played the last video to this assistant. you can see the blue box of the assistant doesn’t show up until after I stop talking completely.
In video 1: with it set to 3, you can see the assistant interrupts the caller before they are done speaking
In video 2: I plan the audio in video 1 back to the assistant for consistency, you can see the assistant doesn’t start to speak until the caller is done
r
Seems to have interupted in about the same spot in both videos right?
g
no
in video two
you hear the interruption from the assistant in video 1. this still doesn’t triiger the assistant to talk .
so let me clarify
the assistant is talking when you see the blue bubble pop up
instead of making a second call
with me talking
I played the audio from video one to the assistaant
in video 2
does that make sense?
you hear the video 1 interruption in video 2, which still doesn’t trigger the assistant to speak prematurely
the blue bubble doesnt appear until she says “Got it. I know no cool air is never fun, let me get your first and last name.”
i’ll remake the videos, so its less confusing
give me a sec
MIN-WORDS-1.mp4
here is min words set to 1
notice how the assistant waits until the caller is done speaking
Now, using the same caller audio here is what it looks like with min words set to 3
MIN-WORDS-3.mp4
this is reproducible every time
anything that isnt the default setting for both these will cause the assistant to interrupt the caller
MIN_INTERRUPTION_DURATION MIN_INTERRUPTION_WORDS
r
Did you say that is a recording that is the input?
Looking at timing. It seems different
Ignore initial time window..
g
yes it is a recording
r
ok, let me have the recording and I can try it
g
min-words-audio.mp3
so that is the audio from video 1 (without interruption)
i used that audio to make video 2 (where assistant interrupts caller)
to test, all you need to do is just speak like you are explaining something
no quick answers etc
r
Do you intentially have really low gain on the audio?
g
no, its just cuz its the audio from video one
all of it is being picked up because we display the transcription
the stt
and it is accurately transcribing the speech
but before we did these tests, we were running into without using recordings
r
So it would be ok to normalize the audio file before feeding it into the agent?
g
sure
because, before using the recording. we were just takling to it by reading a script
i just thought that the issue was may a millisecond difference in the pause was the reason
so i asked everyone to test using recording to eliminate timing as a factor
r
So this should be fine to test with?
g
yes
i’ll use this to make another video
here is min words set to 1
r
Screen recorde did not do a good job of getting the audio but here are my tests with that file
g
MIN-WORDS-1-NORMALIZED.mp4
this video is min words et to 1
this is min words set to 3
can you share you settings
r
the full code I ran is above
And I used this client: https://agents-playground.livekit.io
g
is this voice from deepgram?
in your video
g
so no clue as to why my version is interrupting liek that when its set to 3?
b
Is there a problem with this?
Copy code
session = AgentSession(
            stt=self.get_stt(),
            llm=self.get_llm(),
            tts=self.get_tts(),
            vad=self.ctx.proc.userdata["vad"],
            turn_detection=turn_detection,
            max_endpointing_delay=float(os.getenv("MAX_ENDPOINTING_DELAY", "6.0")),
            user_away_timeout=self.user_away_timeout,
            min_interruption_duration=float(os.getenv("MIN_INTERRUPTION_DURATION", "0.5")),
            min_interruption_words=int(os.getenv("MIN_INTERRUPTION_WORDS", "0")),
            preemptive_generation=preemptive_generation, 
        )
g
1 works perfect
b
@refined-appointment-81829 Does it matter if we use deepgram and cartesia? I tried your sample code with deepgram, cartesia and min_interruption_words=3, and AI will interrupt the caller.
g
@refined-appointment-81829 to confirm, if we use the sample code you provided with deepgram+cartesia, it breaks
can you try on your end to make sure this is consistent?
i just want to rule out some compatibility issue with these settings plus those providers
@refined-appointment-81829 here is your sample code with deepgram and cartesia. It does the same cutting off as min-words-3 now
@refined-appointment-81829 we an consistently reproduce the assistant interruption with min words is set to 3 using your sample code. the only difference is that we are using deepgram and cartesia. are these currently not supported with this feature in LK?
r
Ok, when I looked yesterday setting that did not make all that much difference. I can try deepgram and cartesia.
g
thanks. i just want to rule it
r
have you tried setting the min interrupt duration
g
yes
to .7
.5. to .7
same consequence
it feels like any setting other than default breaks turn detection
j
from the video it seems the transcripts are split into multiple chunks by STT so the agent will try to start a reply for each chunk, and if the reply is not interrupted by the new user input, it feels like the agent is interrupting the user. can you try to increase the
min_endpointing_delay
so the agent will wait for a longer time before start a reply?
another thing we can try is to make the reply that playout not started easier to be interrupted/paused, like ignoring the
min_interruption_words
when agent speaking not started.
g
would min_endpointing_delay increase the latency for the assistant to respond?
my biggest concern is that MIN_INTERRUPTION_WORDS is changing the behavior of the assistant
specifically, it is causing the assistant to interrupt prematurely
increasing the min_endpointing_delay seems it would force the agent to wait longer to respond isn’tead of using context for turn detection like AI is supposed to
j
would min_endpointing_delay increase the latency for the assistant to respond?
most likely not if
preemptive_generation
is enabled, it will start LLM generation once user transcript received and cache there until the
min_endpointing_delay
reached
g
before I do that, could you please confirm that the sample code provided by CWilson does not show the same symtoms we see
the reason is, if deepgram and cartesia are not working properly, I’d like to switch to somethign compatible with LiveKit
j
specifically, it is causing the assistant to interrupt prematurely
MIN_INTERRUPTION_WORDS is to make the agent harder to be interrupted but not how agent interrupt the user. I think your issue is the reply to the former user transcript chunks cannot be canceled in time so the agent speaking starts before user speaking finished.
g
correct. when I left min_interruption_words to the default value, everything works as expected. Howeer, the caller can utter 1 single word to stop the assistant from speaking
that is why we changed it to “3”
so that it would be harder to interrupt the assistant
That works great, it now take 3 words to interrupt the assistant
but the unintended consequence (as seen in the videos I attached), the assistant now interrupts the caller
Here is the video. When MIN_INTERRUPTION_WORDS is left to the default value of 1. the assistant does NOT interrupt the caller
now, when I upate the MIN_INTERRUPTION_WORDS to 3, this is the result (which should not have affected the assistant at all)
with MIN_INTERRUPTION_WORDS set to 3, it interrupts after I proved “My name is Vincent”……which is not even related to the MIN_INTERRUPTION_WORDS.
You can consistently reproduce this exact same issue using CWilson’s sample code, IF you change to using deepgram and cartesia
j
I understand what you mean, and it happens when the transcripts are split into multiple chunks before user speaking done, so it’s a combination of stt, the response delay, and how hard the reply can be cancelled.
you could try to tune any part of these three (min_endpointing_delay, min_interruption_words, and a different STT)
enabling
preemptive_generation
with a larger
min_endpointing_delay
won’t affect the end to end latency
g
ok thank you for the suggestion
we implemented your suggestion. the overall latency has gone up. Most noticible in EOU where it is now at least 1 second. this makes the total latency about 25% slower
@jolly-air-155 we can confirm that EOU is now consistently slower with the min_endpointing_delay increasing latency by about 25%. I also want to stress that if we do not change MIN_INTERRUPTION_WORDS from default, there is no interruption. To be clear, I don’t think changing MIN_INTERRUPTION_WORDS should have any affect on the assistant interrupting the caller BUT it does
r
MIN_INTERRUPTION_WORDS
will have an effect. In your videos above what looks like happens is with 1, and 3 agents starts the respond. But with 3 it takes longer to interrupt the agent so you "feel" it more. That is the whole point of increasing min interrupt words.
➕ 1
j
Do you have preemptive generation enabled? And what is your end to end latency?
To clarify, eou latency increase doesn’t mean the end to end latency is increased when preemptive generation enabled, check this example https://github.com/livekit/agents/blob/44b212083b994db7f8dec420b74536e1361bf752/examples/voice_agents/preemptive_generation.py#L65-L73
g
@refined-appointment-81829 regarding your last comment about what should happen when MIN_INTERRUPTION_WORDS is set to 3, that is currently working perfectly for the AGENT. Meaning, it takes 3 words to interrupt the AGENT. That is the desired effect. What I’m saying is that a side-effect that I do NOT believe is intended, is the AGENT now will interrupt the caller before they are done speaking. I believe setting MIN_INTERRUPTION_WORDS should have no effect on the the AGENT interrupting the caller. But that is not the case. @jolly-air-155 Regarding end-to-end latency, do I understand that EOU will go up if i set the MIN_ENDINGPOINT_DELAY to 3 seconds, but the pre-emptive generation should decrease the latency of the LLM, hence why you believe end-to-end will not increase since it is basically wash (e.g. one goes up while the other goes down)
r
But agent is trying to interrupt user the same in both cases but in the 3 word case it is harder to get the agent to stop where in the 1 word case it is happens before you hear it.
g
ok so to confirm, this is the right behavior?
MIN_INTERRUPTION_WORDS = default value
the AGENT will not interrupt the caller (weird that it affects the agent)
MIN_INTERRUPTION_WORDS set to 2 (now the agent interrupts the caller)
the way the documentation reads, this setting should affect the ability of the caller to interrupt the agent, not the other way around
what setting prevents the caller from interrupting agent?
the caller often says something like “Yes” or “OK” while the ai assistant is speaking, which cuts it off abruptly
which setting will say , only cut the ai assistant off if the caller speaks 2 or more words
btw, the gray boxes are the caller
the box is the ai-assistant
i just want to make sure we are on the same page
it isn’t the agent that is being interrupted when I change MIN_INTERRUPTION_WORDS. it is the caller that is interrupted
j
I think @refined-appointment-81829 already explained it, this is expected, agent is harder to be interrupted, so user feels like the agent is interrupting them
and we are going to revert the
min_endpointing_delay
to 0.5s (it was reduced to 0.4s a few versions before), since the root cause is the agent didn’t wait enough time for user to finish and we see some other reports for similar issues https://github.com/livekit/agents/pull/3416
g
ok, which setting will prevent the caller from interrupting the ai assistant?
or what is the best way to prevent the caller from interrupting the agent
r
you can set allow interrupt = false
g
yes, i just feel like that may be too rigid