Skip to content

fix(mistralai): standardize API error handling - #7308

Open
jeanprbt wants to merge 1 commit into
livekit:mainfrom
jeanprbt:jeanprbt/standardize-mistral-errors
Open

jeanprbt wants to merge 1 commit into
livekit:mainfrom
jeanprbt:jeanprbt/standardize-mistral-errors

Conversation

@jeanprbt

Copy link
Copy Markdown
Contributor

Summary

Standardize Mistral error handling across LLM, STT, and TTS while preserving provider error details and retry semantics.

Motivation

With an invalid LLM model such as foo, Mistral returns HTTP 400 with error code 3003.

Model foo is currently not in use.

The LLM plugin previously handled Mistral's SDKError as a generic exception, turning this non-retryable API response into a retryable APIConnectionError. One user turn therefore produced four misleading Connection error events, the
initial request plus three retries.

Changes

  • Translate Mistral SDKError and HTTPValidationError into APIStatusError across LLM, STT, and TTS.
  • Preserve the provider status, body, and x-request-id.
  • Translate actual asyncio/httpx timeouts into APITimeoutError.
  • Preserve LLM stream retryability so errors after output begins are not retried, avoiding duplicated partial output.

Ordinary 4xx responses are now non-retryable, while transient statuses continue to follow APIConnectOptions.

Tests

  • HTTP 400 is attempted once and remains an APIStatusError.
  • HTTP 422 preserves its status, body, and request ID.
  • An error after the first streamed chunk is not retried.
uv run pytest tests/test_plugin_mistralai_llm.py -q

@jeanprbt
jeanprbt requested a review from a team as a code owner September 16, 2026 11:51

@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.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

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