Skip to content

fix: apply session error tolerance to STT#5997

Open
he-yufeng wants to merge 1 commit into
livekit:mainfrom
he-yufeng:fix/stt-error-tolerance
Open

fix: apply session error tolerance to STT#5997
he-yufeng wants to merge 1 commit into
livekit:mainfrom
he-yufeng:fix/stt-error-tolerance

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • apply the existing max_unrecoverable_errors tolerance to unrecoverable STT errors
  • reset the STT error counter alongside the existing LLM/TTS counters
  • update the connection option docstring and add a focused regression test

Fixes #5665.

To verify

  • python -m py_compile livekit-agents\livekit\agents\voice\agent_session.py tests\test_agent_session.py
  • python -m ruff check livekit-agents\livekit\agents\voice\agent_session.py tests\test_agent_session.py
  • python -m ruff format --check livekit-agents\livekit\agents\voice\agent_session.py tests\test_agent_session.py
  • PYTHONPATH=livekit-agents python -m pytest tests\test_agent_session.py::test_stt_errors_use_unrecoverable_error_tolerance -q

Note: ruff check completed successfully locally but could not write one .ruff_cache entry due a Windows cache permission warning.

@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 found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines 1496 to 1505
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:

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.

🚩 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)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

bug: STT errors close AgentSession immediately, lacking the tolerance counter that LLM and TTS errors have

1 participant