Repository navigation
feat(inference): log when a TTS fallback model serves a turn - #8933
Open
russellmartin-livekit wants to merge 1 commit into
Open
russellmartin-livekit wants to merge 1 commit into
russellmartin-livekit wants to merge 1 commit into
Conversation
When LiveKit Inference reports a fallback_activated notice, log it once before emitting the event, so a raising handler cannot hide it: - system_default: a warning naming the model and cause, with a link to the fallback docs so users can configure their own fallback models. - fallback (or an unknown type): an info line naming the model and cause. Malformed notices keep the existing warning and emit nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
This branch has not been deployed
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.
When LiveKit Inference TTS switches a turn to a fallback model, it sends a
fallback_activatednotice. The SDK emits it as an event but logs nothing, so an agent that does not subscribe to the event never learns that a different voice spoke. This matters most for a system default voice: the primary model failed, no fallback was configured, and LiveKit chose a voice.Change
The SDK now logs each valid notice once, before it emits the event, so a handler that raises cannot suppress the log.
system_default: a warning with the model and cause, and a link to https://docs.livekit.io/agents/logic/fallback-strategies/#inference for configuring your own fallbacks.fallbackor an unknown type: an info line with the model and cause, and no link.Both lines carry
session_id,provider,model,voiceandcauseas structured fields. The message names the model alone because the notice'smodelalready includes the provider, for exampledeepgram/aura-2. Thefallback_activatedevent is unchanged. A malformed notice keeps the existing warning and emits nothing.Verified
uv run pytest tests/test_inference_tts.py: 57 passed. The new tests cover the warning and its structured fields, that the log comes before the event, the info line forfallbackand for an unknown type, and malformed notices. Without the source change, the 3 new logging tests fail.ruff checkandruff format --checkpass on both changed files.mypy -p livekit.agents, run as in CI: no issues.... serving this turn (inworld/inworld-tts-2, cause: provider_error). To choose your own fallback models, see https://docs.livekit.io/agents/logic/fallback-strategies/#inference; a configured fallback logged one info line,fallback model cartesia/sonic-3 is serving this turn (cause: provider_error).; a run with no failure logged neither. The event fired once per notice and audio arrived in every run. With the agents CLI log setup both lines are visible; with no logging configured at all, Python shows the warning but not the info line.🤖 Generated with Claude Code