feat: Intelligent Interruption Handling for Voice Agents#486
Open
anishh15 wants to merge 11 commits intoDark-Sys-Jenkins:mainfrom
Open
feat: Intelligent Interruption Handling for Voice Agents#486anishh15 wants to merge 11 commits intoDark-Sys-Jenkins:mainfrom
anishh15 wants to merge 11 commits intoDark-Sys-Jenkins:mainfrom
Conversation
…tion - Implement InterruptionFilter class with configurable word lists - Add DEFAULT_BACKCHANNEL_WORDS (yeah, ok, mhmm, uh-huh, etc.) - Add DEFAULT_INTERRUPT_WORDS (stop, wait, no, actually, etc.) - Support flexible matching for hyphenated words (uh-huh matches uh huh) - Add should_interrupt() method with state-aware filtering logic
- Add interruption_filter_enabled option (default: True) - Add backchannel_words option for custom word sets - Add interrupt_words option for custom interrupt triggers - Update AgentSessionOptions dataclass with new fields
- Add state tracking flags for utterance filtering - Capture agent state at start of user speech (before VAD/STT race) - Apply filter in _interrupt_by_audio_activity() method - Skip interruption for backchannel words when agent is speaking - Reset filter state on end of speech
- Add should_skip_turn_detection() hook to RecognitionHooks - Skip End-of-Utterance detection when backchannel is filtered - Prevents agent from generating response to ignored input
- Export InterruptionFilter, InterruptionFilterConfig - Export DEFAULT_BACKCHANNEL_WORDS, DEFAULT_INTERRUPT_WORDS
- Fix initialization issue causing agent startup failure
- Test default configuration and custom word sets - Test backchannel blocking when agent is speaking - Test interrupt word detection - Test mixed input handling (yeah but wait) - Test case insensitivity and punctuation handling - Test dynamic configuration updates
- Create DemoAgent storyteller for testing backchanneling - Configure AgentSession with interruption filter enabled - Include setup instructions and usage examples
- Document backchannel filtering while agent speaking - Document interrupt word detection - Document response when agent is silent - Include test results summary
- Document architecture and design decisions - Explain state capture timing for VAD/STT race condition - List all modified and new files - Include setup and testing instructions
There was a problem hiding this comment.
Pull request overview
This PR implements intelligent interruption handling for voice agents that distinguishes between passive acknowledgements (backchanneling) and actual interruptions. The feature filters backchannel words like "yeah", "mhmm", and "okay" when the agent is speaking, allowing conversations to flow naturally without unnecessary interruptions.
Changes:
- Added
InterruptionFilterclass with configurable word lists and state-aware filtering logic - Integrated filter into
AgentActivitywith state capture timing to handle VAD/STT race conditions - Modified
AudioRecognitionto skip EOU (End-of-Utterance) detection for filtered backchannel utterances - Added configuration options to
AgentSessionfor enabling/customizing the filter - Included comprehensive test suite (21 tests), demo agent, and documentation
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
livekit-agents/livekit/agents/voice/interruption_filter.py |
New core filter implementation with regex-based word matching and state-aware logic |
livekit-agents/tests/test_interruption_filter.py |
Comprehensive unit tests covering filter behavior in various scenarios |
examples/voice_agents/interrupt_demo.py |
Demo agent showcasing the interruption handling feature |
proof/transcript.txt |
Annotated transcript demonstrating filter behavior |
CHANGES.md |
Documentation explaining architecture, configuration, and design decisions |
livekit-agents/livekit/agents/voice/agent_activity.py |
Integration point: state capture, filter application, and flag management |
livekit-agents/livekit/agents/voice/audio_recognition.py |
Modified to skip EOU detection for filtered utterances using new hook |
livekit-agents/livekit/agents/voice/agent_session.py |
Added configuration options for filter enable/disable and custom word lists |
livekit-agents/livekit/agents/voice/__init__.py |
Exported filter classes and constants to public API |
livekit-agents/livekit/agents/telemetry/traces.py |
Added compatibility for newer opentelemetry-sdk versions (unrelated to main feature) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove unused Literal import from interruption_filter.py - Remove duplicate Any import from traces.py - Remove unused was_filtered variable from agent_activity.py - Re-enable resume_false_interruption in demo agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Implements context-aware interruption handling that distinguishes between passive acknowledgements (yeah, mhmm, okay) and actual interruptions (stop, wait, no) based on agent speaking state.
Key Features
Files Added
interruption_filter.pyinterrupt_demo.pytest_interruption_filter.pyproof/Files Modified
agent_activity.pyaudio_recognition.pyagent_session.py__init__.pyUsage
Documentation
See CHANGES.md for detailed architecture and configuration guide.