Skip to content

fix(tts): keep fallback child errors internal - #2425

Open
swayamg20 wants to merge 1 commit into
livekit:mainfrom
swayamg20:fix/2399-tts-fallback-recoverability
Open

fix(tts): keep fallback child errors internal#2425
swayamg20 wants to merge 1 commit into
livekit:mainfrom
swayamg20:fix/2399-tts-fallback-recoverability

Conversation

@swayamg20

Copy link
Copy Markdown

Description

Fixes #2399 by keeping child provider errors internal while FallbackAdapter tries the next TTS. The adapter emits one terminal unrecoverable error only after every provider fails.

Changes Made

  • Replace child error forwarding with private sinks, while preserving external listeners during cleanup.
  • Safely handle transient StreamAdapter instances used for non-streaming providers.
  • Add coverage for successful failover, terminal exhaustion, duplicate children, cleanup, and non-streaming fallback.

Pre-Review Checklist

  • Build passes: @livekit/agents build, lint, typecheck, and tests pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are documented and justified above
  • Scope appropriate: All changes relate to the PR title
  • Video demo: Not applicable to this internal TTS event-handling fix

Testing

  • Automated tests added/updated
  • All @livekit/agents tests pass
  • restaurant_agent.ts and realtime_agent.ts: Not applicable; this is not a major change

Additional Notes

  • Focused FallbackAdapter tests: 10 passed
  • Full TTS suite: 100 passed
  • Full Agents suite: 2,439 passed, 5 skipped

Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

@swayamg20
swayamg20 requested a review from a team as a code owner September 4, 2026 23:57
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b48b8ff

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

This PR includes changesets to release 38 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-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.

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.

tts.FallbackAdapter forwards child error events with recoverable: false, closing the AgentSession even though the adapter is switching to the next TTS

1 participant