Skip to content

fix(inference): enable STT websocket heartbeat - #5883

Closed
he-yufeng wants to merge 1 commit into
livekit:mainfrom
he-yufeng:fix/inference-stt-heartbeat
Closed

he-yufeng wants to merge 1 commit into
livekit:mainfrom
he-yufeng:fix/inference-stt-heartbeat

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • enable aiohttp WebSocket heartbeat for LiveKit Inference STT streams
  • keep normal quiet-user sessions untouched because heartbeat uses WS PING/PONG, not application message timeouts
  • cover the connection path with a fake-session unit test

Fixes #5717.

To verify

  • python -m py_compile livekit-agents\livekit\agents\inference\stt.py tests\test_inference_stt_fallback.py
  • uv run ruff check livekit-agents\livekit\agents\inference\stt.py tests\test_inference_stt_fallback.py
  • uv run ruff format --check livekit-agents\livekit\agents\inference\stt.py tests\test_inference_stt_fallback.py
  • uv run pytest tests\test_inference_stt_fallback.py -q

@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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Gentle bump. Long quiet STT sessions still drop on idle websocket timeouts. This enables aiohttp PING/PONG heartbeat only for the inference STT streams, so normal quiet-user sessions are completely untouched (no application-level pings). Happy to make it configurable if you'd rather gate it.

f"{base_url}/stt?model={self._opts.model}", headers=headers
f"{base_url}/stt?model={self._opts.model}",
headers=headers,
heartbeat=WS_HEARTBEAT,

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.

this only check the connection between client to the gateway, but cannot fix the issue described in the original issue

If the gateway WebSocket connects successfully but the upstream STT provider (Deepgram, etc.) silently stops returning transcripts — e.g., the gateway-to-provider tunnel goes flaky, or TCP goes half-open — the recv loop will block indefinitely.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

longcw's review pointed out the heartbeat covers client↔gateway, not the gateway→provider silence from the original issue; I have not reworked it in 59 days. Closing until a real fix exists.

@he-yufeng he-yufeng closed this Sep 19, 2026
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.

fix(inference): add per-message recv timeout to inference STT WebSocket

2 participants