Skip to content

fix(voice): preserve held STT turn boundaries - #2319

Open
Thytu wants to merge 1 commit into
livekit:mainfrom
Thytu:fix/preserve-held-stt-turn-boundary
Open

fix(voice): preserve held STT turn boundaries#2319
Thytu wants to merge 1 commit into
livekit:mainfrom
Thytu:fix/preserve-held-stt-turn-boundary

Conversation

@Thytu

@Thytu Thytu commented Aug 21, 2026

Copy link
Copy Markdown

Description

Preserve an accepted STT turn boundary when agent speech starts between the final transcript and its END_OF_SPEECH sentinel.

The final transcript is accepted before agent speech, but the following sentinel is buffered while the agent is speaking. During the later flush, the sentinel has no transcript alternatives, so it cannot set shouldFlush and is discarded. The user turn remains uncommitted and can be merged with later speech.

Changes Made

  • Re-emit a held END_OF_SPEECH when STT has accepted transcript text for an uncommitted turn.
  • Keep the exception scoped to STT turn detection and buffers that actually contain the pending boundary.
  • Add a regression covering the exact final → agent speech → end sentinel → agent speech end ordering.
  • Add a patch changeset for @livekit/agents.

Pre-Review Checklist

  • Build passes: Full monorepo build and typecheck pass locally
  • AI-generated code reviewed: Comments and test setup were reviewed and kept to the state-machine invariant
  • Changes explained: The failed transition and bounded exception are documented above
  • Scope appropriate: Only held STT turn-boundary handling and its regression are changed
  • Video demo: Not applicable; this is an internal event-ordering race covered by a deterministic regression

Testing

  • Regression fails on main with userTurnCommitted === false
  • Regression passes with the fix
  • pnpm test agents/src — 136 files passed; 2,248 tests passed; 5 skipped
  • pnpm build
  • pnpm typecheck
  • pnpm format:check
  • pnpm -w lint:fix

Additional Notes

The unscoped test command also runs provider/example integration tests. Locally those reported unrelated missing OPENAI_API_KEY/CEREBRAS_API_KEY, Hugging Face download timeouts, and one FishAudio assertion. The complete agents/src suite passes.

@Thytu
Thytu requested a review from a team as a code owner August 21, 2026 18:28
@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 67385f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 39 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

1 participant