Skip to content

fix(fallback): prewarm all instances in LLM/STT/TTS FallbackAdapters; fix soniox RECOGNITION_USAGE under-reporting - #6589

Open
priyam-garg wants to merge 1 commit into
livekit:mainfrom
priyam-garg:fix/fallback-adapter-prewarm-and-soniox-usage
Open

fix(fallback): prewarm all instances in LLM/STT/TTS FallbackAdapters; fix soniox RECOGNITION_USAGE under-reporting#6589
priyam-garg wants to merge 1 commit into
livekit:mainfrom
priyam-garg:fix/fallback-adapter-prewarm-and-soniox-usage

Conversation

@priyam-garg

Copy link
Copy Markdown

Summary

This PR fixes two independent bugs found in the fallback adapters and Soniox plugin.


Bug 1 — RECOGNITION_USAGE under-reporting in livekit-plugins-soniox (fixes #6584)

Root cause: _report_processed_audio_duration() was only called on endpoint
tokens (<end> / <fin>) and on finished/has_error messages. Every
interim-only message silently advanced total_audio_proc_ms without emitting
a RECOGNITION_USAGE event, causing heavy under-reporting of STT usage.

Fix: Call _report_processed_audio_duration(total_audio_proc_ms) unconditionally
at the end of every message. The helper's _reported_duration_ms delta tracking
already prevents double-counting.


Bug 2 — FallbackAdapter.prewarm() does not warm fallback providers

All three fallback adapters had the same bug: when a primary provider fails,
the fallback's connection is cold (no DNS, no TLS), adding latency exactly
when it matters most.

Adapter Before After
tts.FallbackAdapter Only prewarmed _tts_instances[0] Prewarms all instances
stt.FallbackAdapter No prewarm() at all Prewarms all instances
llm.FallbackAdapter No prewarm() at all Prewarms all instances

Files Changed

  • livekit-plugins/livekit-plugins-soniox/livekit/plugins/soniox/stt.py
  • livekit-agents/livekit/agents/tts/fallback_adapter.py
  • livekit-agents/livekit/agents/stt/fallback_adapter.py
  • livekit-agents/livekit/agents/llm/fallback_adapter.py

Checklist

  • ruff check — All checks passed
  • ruff format --check — All files already formatted

… fix soniox RECOGNITION_USAGE under-reporting

- LLM FallbackAdapter: add prewarm() that delegates to all contained LLM
  instances. Previously missing entirely, leaving every fallback LLM cold.

- STT FallbackAdapter: add prewarm() that delegates to all contained STT
  instances. Previously missing entirely.

- TTS FallbackAdapter: fix prewarm() to iterate all TTS instances instead
  of only prewarm()'ing index [0]. When the primary fails, fallback
  providers must already have warm connections to avoid a latency spike.

- livekit-plugins-soniox: fix RECOGNITION_USAGE under-reporting (livekit#6584).
  Previously _report_processed_audio_duration() was only called on endpoint
  tokens (<end>/<fin>) and on finished/error messages, silently skipping
  every interim-only message. Now called unconditionally after each message;
  the helper's internal delta tracking (_reported_duration_ms) prevents
  any double-counting.
@priyam-garg
priyam-garg requested a review from a team as a code owner July 28, 2026 18:19
Copilot AI review requested due to automatic review settings July 28, 2026 18:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CLAassistant

CLAassistant commented Jul 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

livekit-plugins-soniox: RECOGNITION_USAGE only reported on endpoint tokens, under-reporting STT usage

3 participants