Skip to content

fix(mistral): mistral user parameter#680

Merged
daavoo merged 6 commits intomozilla-ai:mainfrom
keem-hyun:fix/mistral-user-parameter
Dec 23, 2025
Merged

fix(mistral): mistral user parameter#680
daavoo merged 6 commits intomozilla-ai:mainfrom
keem-hyun:fix/mistral-user-parameter

Conversation

@keem-hyun
Copy link
Copy Markdown
Contributor

Mistral API does not support the 'user' parameter that is part of OpenAI's standard API. This fix adds 'user' to the exclude list in _convert_completion_params() to prevent TypeError.

Description

Fixes a TypeError in the Mistral provider when the user parameter is included in completion requests.

Root cause:
The Mistral API does not support the OpenAI-standard user parameter, but MistralProvider._convert_completion_params() was not excluding it when converting CompletionParams to Mistral API format.

Changes:

  • Added "user" to the exclude list in src/any_llm/providers/mistral/mistral.py (line 61)
  • Updated comment to reflect that both reasoning_effort and user parameters are not supported

Code change:

# Before
converted_params = params.model_dump(
    exclude_none=True, exclude={"model_id", "messages", "response_format", "stream"}
)

# After
converted_params = params.model_dump(
    exclude_none=True, exclude={"model_id", "messages", "response_format", "stream", "user"}
)

PR Type

🐛 Bug Fix

Relevant issues

Fixes #679

Checklist

  • I have added unit tests that prove my fix/feature works
  • New and existing tests pass locally
  • Documentation was updated where necessary
  • I have read and followed the contribution guidelines

Mistral API does not support the 'user' parameter that is part of
OpenAI's standard API. This fix adds 'user' to the exclude list in
_convert_completion_params() to prevent TypeError.
- Add test_user_parameter_excluded for non-streaming mode
- Add test_user_parameter_excluded_streaming for streaming mode
- Verify user parameter is excluded from Mistral API calls
@keem-hyun keem-hyun changed the title Fix/mistral user parameter fix(mistral): mistral user parameter Dec 23, 2025
daavoo
daavoo previously approved these changes Dec 23, 2025
Copy link
Copy Markdown
Contributor

@daavoo daavoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @keem-hyun !

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/any_llm/providers/mistral/mistral.py 84.41% <ø> (-12.99%) ⬇️

... and 43 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@daavoo daavoo merged commit 80e846a into mozilla-ai:main Dec 23, 2025
8 of 9 checks passed
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] mistral: TypeError when 'user' parameter is provided in completion request

2 participants