Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions livekit-agents/livekit/agents/voice/agent_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def __init__(
# unrecoverable error counts, reset after agent speaking
self._llm_error_counts = 0
self._tts_error_counts = 0
self._stt_error_counts = 0

# aec warmup: disable interruptions while AEC warms up
self._aec_warmup_remaining = aec_warmup_duration or 0.0
Expand Down Expand Up @@ -997,6 +998,7 @@ async def _aclose_impl(
self._agent_state = "initializing"
self._llm_error_counts = 0
self._tts_error_counts = 0
self._stt_error_counts = 0
self._root_span_context = None

if self._session_host:
Expand Down Expand Up @@ -1384,6 +1386,10 @@ def _on_error(
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:
Expand Down Expand Up @@ -1478,6 +1484,7 @@ def _update_agent_state(
if state == "speaking":
self._llm_error_counts = 0
self._tts_error_counts = 0
self._stt_error_counts = 0

if self._agent_speaking_span is None:
self._agent_speaking_span = tracer.start_span(
Expand Down
Loading