Skip to content

feat(inference): log when a TTS fallback model serves a turn - #8933

Open
russellmartin-livekit wants to merge 1 commit into
mainfrom
feat/inference-tts-fallback-log
Open

russellmartin-livekit wants to merge 1 commit into
mainfrom
feat/inference-tts-fallback-log

Conversation

@russellmartin-livekit

Copy link
Copy Markdown
Contributor

When LiveKit Inference TTS switches a turn to a fallback model, it sends a fallback_activated notice. 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.

Both lines carry session_id, provider, model, voice and cause as structured fields. The message names the model alone because the notice's model already includes the provider, for example deepgram/aura-2. The fallback_activated event 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 for fallback and for an unknown type, and malformed notices. Without the source change, the 3 new logging tests fail.
  • ruff check and ruff format --check pass on both changed files.
  • mypy -p livekit.agents, run as in CI: no issues.
  • End to end against a LiveKit Inference test environment, with the primary model forced to fail before audio (2 runs per case): a system default substitution logged one warning, ... 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

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>
@russellmartin-livekit
russellmartin-livekit requested a review from a team as a code owner December 4, 2026 04:20
@russellmartin-livekit russellmartin-livekit self-assigned this Dec 4, 2026
@russellmartin-livekit
russellmartin-livekit requested a review from a team December 4, 2026 04:20

@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: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

This branch has not been deployed

No deployments
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.

1 participant