fix(tts): don't mark FallbackAdapter primary unavailable on abort-before-first-audio#1290
Open
mrniket wants to merge 2 commits intolivekit:mainfrom
Open
fix(tts): don't mark FallbackAdapter primary unavailable on abort-before-first-audio#1290mrniket wants to merge 2 commits intolivekit:mainfrom
mrniket wants to merge 2 commits intolivekit:mainfrom
Conversation
…ore-first-audio A caller interruption within the window between text push and first audio frame was hitting the !sawRawAudio guard in FallbackSynthesizeStream.run and being re-raised as APIConnectionError, which the outer catch translated into markUnAvailable(primary) — forcing subsequent utterances onto the fallback TTS for the recovery window. Treat abort-before-first-audio as a clean interruption: emit END_OF_STREAM and return without throwing. Real silent provider failures are unaffected.
|
…abort - Match the success-path cleanup: await readInputLLMStream on the abort branch too, avoiding a potential dangling promise if input later throws. - Trim verbose test comments and the new source comment.
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
tts.FallbackAdaptermarks the primary provider unavailable whenever aSynthesizeStreamis aborted before its first audio frame arrives. Caller interruptions within the provider's typical TTFA window (a few hundred ms) routinely trip this, forcing subsequent utterances onto the fallback TTS for the entirerecoveryDelayMs— silent dead air during that window if the fallback is misbehaving.Root cause: when the outer abort fires before any audio is received,
FallbackSynthesizeStream.run()drops through to the!sawRawAudioguard and throwsAPIConnectionError("TTS stream completed but no audio was received"). The outer catch cannot distinguish that from a real silent provider failure and callsmarkUnAvailable(i).Changes Made
agents/src/tts/fallback_adapter.ts— Short-circuit the!sawRawAudiobranch inFallbackSynthesizeStream.run()whenabortController.signal.aborted. On abort, emitEND_OF_STREAMand return cleanly instead of throwing. Real silent provider failures (where abort is not signalled) still throw and still mark the primary unavailable.agents/src/tts/fallback_adapter.test.ts— Added a regression test. The primary emits no audio;stream.close()is called before the first frame; the test assertsadapter.status[0].available === true. Without the fix the primary is marked unavailable. The two existing "silent failure triggers fallback" tests still pass, guarding the regression in the other direction.Testing
pnpm vitest run agents/src— 684 passed, 2 skipped.pnpm format:checkclean.mainwithexpected false to be trueand passes with the fix.