Fixes #4243 :Prevent immediate speech interruption in pause mode #4395
+15
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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