Skip to content

feat(inference): make STT/TTS reconnect retries replayable#5401

Draft
shawnfeldman wants to merge 1 commit intomainfrom
sf/inference-gateway-reconnect
Draft

feat(inference): make STT/TTS reconnect retries replayable#5401
shawnfeldman wants to merge 1 commit intomainfrom
sf/inference-gateway-reconnect

Conversation

@shawnfeldman
Copy link
Copy Markdown

Summary

  • Add bounded STT streaming input buffering and replay-on-retry so reconnects can resume from recent audio instead of restarting empty.
  • Reset inference STT per-connection speech state on reconnect and add websocket health checks to pooled inference TTS connections.
  • Add optional APIConnectOptions.tts_replay_on_partial and test coverage for connection pool health checks plus STT reconnect buffering/replay behavior.

Test plan

  • uv run ruff check livekit-agents/livekit/agents/stt/stt.py livekit-agents/livekit/agents/inference/stt.py livekit-agents/livekit/agents/utils/connection_pool.py livekit-agents/livekit/agents/inference/tts.py livekit-agents/livekit/agents/tts/tts.py livekit-agents/livekit/agents/types.py tests/test_connection_pool.py tests/test_stt_reconnect.py
  • uv run pytest tests/test_stt_reconnect.py tests/test_connection_pool.py (blocked in this environment by psutil import failure from tests/conftest.py)

- Add input buffer to STT RecognizeStream for audio frame replay on reconnect
- Reset per-session state (speech_duration, speaking) in inference STT _run()
- Add health_check_cb to ConnectionPool to detect dead pooled WebSocket connections
- Pass ws health check to inference TTS connection pool
- Add tts_replay_on_partial option for TTS retry after partial audio output
- Fix ruff formatting issues that broke CI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shawnfeldman shawnfeldman force-pushed the sf/inference-gateway-reconnect branch from fa1fe55 to 15605e6 Compare April 9, 2026 19:35
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