Skip to content
5 changes: 5 additions & 0 deletions .changeset/tts-fallback-child-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/agents': patch
---

Stop `tts.FallbackAdapter` from closing the session while it is falling back. Child `error` events were re-emitted verbatim, so one provider failure (an ElevenLabs 401, say) closed the session even though the next instance was already serving audio, and the recovery probe re-raised it every `recoveryDelayMs`. The adapter now absorbs a child's failure when it recovers from it, logging the provider's own error, and reports its own error when it can't: every instance failed, or speech was already cut off. A recovery probe that errors no longer counts as recovered, `StreamAdapter` wrappers no longer stay subscribed to non-streaming instances, `close()` removes only the adapter's own listeners, and a failed `ChunkedStream` no longer surfaces as an unhandled rejection.
6 changes: 6 additions & 0 deletions agents/etc/agents.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2657,6 +2657,8 @@ abstract class ChunkedStream implements AsyncIterableIterator<SynthesizedAudio>
// (undocumented)
protected closed: boolean;
collect(): Promise<AudioFrame>;
// @internal
get error(): Error | undefined;
// (undocumented)
get inputText(): string;
// (undocumented)
Expand Down Expand Up @@ -7917,6 +7919,8 @@ class StreamAdapterWrapper extends SpeechStream {
class StreamAdapterWrapper_2 extends SynthesizeStream {
constructor(tts: TTS, sentenceTokenizer: SentenceTokenizer, connOptions?: APIConnectOptions);
// @internal
get error(): Error | undefined;
// @internal
get expressive(): boolean;
// (undocumented)
label: string;
Expand Down Expand Up @@ -8208,6 +8212,8 @@ abstract class SynthesizeStream implements AsyncIterableIterator<SynthesizedAudi
// (undocumented)
static readonly END_OF_STREAM: unique symbol;
endInput(): void;
// @internal
get error(): Error | undefined;
flush(): void;
// (undocumented)
protected static readonly FLUSH_SENTINEL: unique symbol;
Expand Down
Loading
Loading