feat(stt): add FallbackAdapter for automatic STT provider failover#1278
Merged
theomonnom merged 7 commits intolivekit:mainfrom Apr 21, 2026
Merged
feat(stt): add FallbackAdapter for automatic STT provider failover#1278theomonnom merged 7 commits intolivekit:mainfrom
theomonnom merged 7 commits intolivekit:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 2707c1d The changes in this PR will be included in the next version bump. This PR includes changesets to release 26 packages
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 |
…gents-js into feat/stt-fallback-adapter
theomonnom
approved these changes
Apr 21, 2026
This was referenced Apr 21, 2026
Merged
8 tasks
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.
Description
Port the Python
livekit-agents/livekit/agents/stt/fallback_adapter.pyto TypeScript so STT has parity with the existing llm.FallbackAdapter and tts.FallbackAdapter. When the active STT fails, the adapter switches to the next available provider; failed providers are monitored by a parallel probe stream on live audio and flipped back to available on the first non-empty FINAL transcript. Non-streaming STTs are auto-wrapped with stt.StreamAdapter when a VAD is provided.Supersedes the stale #1083. Closes the STT half of #868.
Project specific fork of this adapter has been running in production at Lottie since 2026-04-20 on a LiveKit voice-agent (AssemblyAI primary + Deepgram Flux fallback). Tested by running agent in playground and emitting synthetic error events from primary and fallback STTs.
Changes Made
agents/src/stt/fallback_adapter.ts— new FallbackAdapter + FallbackSpeechStream. Hot-standby recovery probes, mid stream failover, telephony-tuned defaults (attemptTimeoutMs: 10_000, maxRetryPerSTT: 1, retryIntervalMs: 5_000). Child error events deliberately not forwarded — would otherwise cause AgentSession.onModelError to close the session on the first transient provider error and defeat the fallback. Terminal errors still surface via the adapter's own run() throwing APIConnectionError after exhausting all providers.agents/src/stt/fallback_adapter.test.ts— 14 unit tests covering constructor contract, _recognize fallthrough/exhaustion non-APIError handling, stt_availability_changed wiring, background recovery, metrics forwarding, close() detach, and the full streaming path (success / failover / all-fail).agents/src/stt/index.ts— re-export FallbackAdapter, FallbackAdapterOptions, AvailabilityChangedEvent.Pre-Review Checklist
Testing
restaurant_agent.tsandrealtime_agent.tswork properly (for major changes)Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.