Skip to content

fix(livekit-agents): propagate prewarm through the STT fallback and stream adapters - #6583

Open
fxhxdxd wants to merge 1 commit into
livekit:mainfrom
fxhxdxd:fix/stt-prewarm-propagation
Open

fix(livekit-agents): propagate prewarm through the STT fallback and stream adapters#6583
fxhxdxd wants to merge 1 commit into
livekit:mainfrom
fxhxdxd:fix/stt-prewarm-propagation

Conversation

@fxhxdxd

@fxhxdxd fxhxdxd commented Jul 28, 2026

Copy link
Copy Markdown

Follow-up to #6582, where I flagged the same gap on the STT side and offered to cover it separately.

Problem

Both stt.FallbackAdapter and stt.StreamAdapter inherit the no-op STT.prewarm() and neither forwards it, so the prewarm issued by AgentActivity (voice/agent_activity.py:608,724) never reaches the wrapped instances. Providers that implement prewarming — currently the mistralai realtime STT, which warms its connection pool — are therefore never warmed behind either adapter.

The TTS equivalents already forward it (tts/fallback_adapter.py:126-128, tts/stream_adapter.py:68-69), so this brings the STT path in line.

Why both hops

They interact rather than being two independent nits. FallbackAdapter transparently wraps non-streaming STTs in a StreamAdapter (stt/fallback_adapter.py:74-76), so on that path prewarm has to survive the adapter and the wrapper to reach the provider — fixing only FallbackAdapter leaves it swallowed one level down. test_prewarm_reaches_non_streaming_primary covers exactly that chain and still fails with only the FallbackAdapter half applied.

As in #6582, only the primary instance is prewarmed: the remaining instances are not expected to serve traffic unless it fails.

Tests

New tests/test_stt_prewarm.py:

  • test_fallback_adapter_prewarms_primary_stt — primary warmed, fallbacks stay cold.
  • test_stream_adapter_forwards_prewarmStreamAdapter forwards to the wrapped STT.
  • test_prewarm_reaches_non_streaming_primary — prewarm survives both hops when the primary is non-streaming and gets auto-wrapped.

All three fail on main. With only the FallbackAdapter fix, the third still fails, which is what motivates touching StreamAdapter too. ruff check, ruff format --check and mypy --strict are clean on the touched files, and test_stt_prewarm.py, test_stt_fallback.py, test_stt_base.py and test_tts_fallback.py pass together (20 passed).

…tream adapters

`stt.FallbackAdapter` and `stt.StreamAdapter` both inherit the no-op
`STT.prewarm()`, so the prewarm issued by `AgentActivity` never reached the
wrapped instances. Providers that implement prewarming (currently the mistralai
realtime STT, which warms its connection pool) were therefore never warmed when
used behind either adapter.

Both hops matter: `FallbackAdapter` transparently wraps non-streaming STTs in a
`StreamAdapter`, so prewarm has to survive the adapter *and* the wrapper to
reach the provider. `tts.FallbackAdapter` and `tts.StreamAdapter` already
forward it; this brings the STT path in line.

Only the primary instance is prewarmed, matching the TTS adapter, since the
remaining instances are not expected to serve traffic unless it fails.
@fxhxdxd
fxhxdxd requested a review from a team as a code owner July 28, 2026 14:51

@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.

1 participant