Skip to content

Conversation

@Devesh36
Copy link

@Devesh36 Devesh36 commented Nov 6, 2025

Description

This PR resolves an inconsistency in the interruption detection logic for minInterruptionWords within LiveKit agents. Previously, the word count check was skipped for empty or undefined STT transcripts, leading to unwanted interruptions triggered by silence or very short utterances.
Now, interruption filtering based on minInterruptionWords is uniformly enforced across all speech scenarios, ensuring robust and predictable turn detection regardless of transcript content.

Changes Made

  • Removed the condition that skipped word count checks for empty/undefined STT text.
  • Normalized undefined and null transcripts to empty strings for consistent handling.
  • Applied minInterruptionWords filtering uniformly to all speech scenarios.
  • Refactored both onEndOfTurn and onVADInferenceDone to use the same splitWords logic.
  • Added a comprehensive test suite with 23 cases covering:
    • Empty and undefined transcript handling
    • Word count threshold logic
    • Punctuation and whitespace processing
    • Integration scenarios between both methods

All 23 tests pass successfully.

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Unnecessary comments removed, code quality ensured
  • Changes explained: All modifications are documented and justified above
  • Scope appropriate: All changes directly relate to PR title and description

Testing

  • Automated tests added/updated in accordance with new logic
  • All tests pass without exceptions
  • Verified both restaurant_agent.ts and realtime_agent.ts function properly after changes

/fix #785

- Remove condition that skipped word count check for empty/undefined STT text
- Apply minInterruptionWords filtering uniformly to all speech scenarios
- Normalize undefined/null transcripts to empty string for consistent handling
- Update onEndOfTurn to use same splitWords logic as onVADInferenceDone
- Add comprehensive test suite with 23 test cases covering:
  * Empty and undefined transcript handling
  * Word count threshold logic
  * Punctuation and whitespace handling
  * Integration scenarios between both methods

This ensures consistent interruption behavior regardless of transcript content,
preventing unwanted interruptions from silence or very short utterances.

All 23 tests pass successfully.
@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2025

⚠️ No Changeset found

Latest commit: a87516a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Nov 6, 2025

CLA assistant check
All committers have signed the CLA.

…nsive interruption detection tests

- Refactored onVADInferenceDone() to normalize undefined/null text and apply word count check consistently
- Refactored onEndOfTurn() to use splitWords() for consistent word splitting with onVADInferenceDone()
- Added 23 comprehensive unit tests covering all scenarios: empty strings, undefined, short/long speech, thresholds
- All tests passing (23/23)
- Added SPDX headers to REFACTORING_SUMMARY.md for REUSE compliance
@Devesh36
Copy link
Author

Devesh36 commented Nov 7, 2025

please review this @toubatbrian :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minInterruptionWords does not work

2 participants