fix: apply session error tolerance to STT#5997
Conversation
| self._llm_error_counts += 1 | ||
| if self._llm_error_counts <= self.conn_options.max_unrecoverable_errors: | ||
| return | ||
| elif error.type == "stt_error": | ||
| self._stt_error_counts += 1 | ||
| if self._stt_error_counts <= self.conn_options.max_unrecoverable_errors: | ||
| return | ||
| elif error.type == "tts_error": | ||
| self._tts_error_counts += 1 | ||
| if self._tts_error_counts <= self.conn_options.max_unrecoverable_errors: |
There was a problem hiding this comment.
🚩 RealtimeModelError has no error tolerance in _on_error
Pre-existing issue: _on_error at livekit-agents/livekit/agents/voice/agent_session.py:1489-1506 accepts llm.RealtimeModelError in its type signature, but the if/elif chain only checks for llm_error, stt_error, and tts_error types. A RealtimeModelError (which has type: Literal["realtime_model_error"] per livekit-agents/livekit/agents/llm/realtime.py:52) would fall through all branches and immediately trigger session close with zero tolerance, unlike LLM/STT/TTS which get max_unrecoverable_errors retries. This is not introduced by the PR but is worth noting since the PR touched this exact method and could have addressed it for completeness.
(Refers to lines 1495-1506)
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
max_unrecoverable_errorstolerance to unrecoverable STT errorsFixes #5665.
To verify
python -m py_compile livekit-agents\livekit\agents\voice\agent_session.py tests\test_agent_session.pypython -m ruff check livekit-agents\livekit\agents\voice\agent_session.py tests\test_agent_session.pypython -m ruff format --check livekit-agents\livekit\agents\voice\agent_session.py tests\test_agent_session.pyPYTHONPATH=livekit-agents python -m pytest tests\test_agent_session.py::test_stt_errors_use_unrecoverable_error_tolerance -qNote:
ruff checkcompleted successfully locally but could not write one.ruff_cacheentry due a Windows cache permission warning.