Fixes #4243 :Prevent immediate speech interruption in pause mode#4395
Fixes #4243 :Prevent immediate speech interruption in pause mode#4395devbyteai wants to merge 1 commit intolivekit:mainfrom
Conversation
When using STT turn detection with resume_false_interruption=True, the agent incorrectly interrupted speech during the false interruption timeout period, causing phantom "thinking->listening" transitions. Root cause: In on_final_transcript(), after pausing the speech and starting the false interruption timer, the code unconditionally called _interrupt_paused_speech() which cancelled the timer and interrupted the speech immediately - defeating the pause mode. Solution: When in pause mode (resume_false_interruption=True, timeout set, audio supports pause), return early after starting the timer. Let the timer decide whether to resume (false interruption) or let the next real end-of-turn event handle the actual interruption. This fix: - Only affects users with resume_false_interruption=True - Maintains backward compatibility for other configurations - Preserves correct behavior for real end-of-turn interruptions - Fixes console mode phantom VAD activity issues Fixes livekit#4243
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
If the issue was caused by transcriptions from backchannels like "emm.." "yeah.", we are going to release a backchannel detection model to ignore the interruptions caused by that #4319. |
Summary
Fixes #4243
This PR fixes the phantom VAD activity issue that caused unwanted interruptions when using STT turn detection with
resume_false_interruption=True.Problem
When using STT turn detection (especially with Deepgram) and
resume_false_interruption=True, the agent incorrectly interrupted speech during the false interruption timeout period. This caused:llm_nodegets cancelled unexpectedlyUser-Reported Behavior:
Root Cause
In
on_final_transcript()(agent_activity.py), after pausing the speech and starting the false interruption timer, the code unconditionally called_interrupt_paused_speech():The
_interrupt_paused_speech()method:interrupt()on the paused speechThis defeated the entire purpose of the pause mode, which was designed to allow speech to resume if the interruption was a false positive.
Solution
When in pause mode (
resume_false_interruption=True,false_interruption_timeoutset, audio supports pause), return early after starting the timer. Let the timer decide whether to:Testing
Unit Tests
All 15 existing agent session tests pass:
What Tests Verify
resume_false_interruption=True- Tests that speech correctly resumes after false interruption timeoutresume_false_interruption=False- Tests backward compatibilityManual Testing Recommended
For production verification, test with:
Backward Compatibility
resume_false_interruption=Trueresume_false_interruption=Falsesee no changeImpact Analysis
Console Mode
WebRTC Mode
resume_false_interruption=TrueRealtime LLM
Manual Turn Detection
Edge Cases Handled
on_start_of_speech()(already implemented)_user_turn_completed_taskstill interrupts correctly_interrupt_paused_speechcalled during cleanupFiles Changed
livekit-agents/livekit/agents/voice/agent_activity.py- Fix inon_final_transcript()methodFuture Considerations
_interrupt_paused_speechshould be reviewedresume_false_interruptionbehavior more clearly