litellm/tests/unit/llms/mistral
ellisc42 1d73166a74
fix(mistral): map tool call ids to Mistral's 9-char shape on Vertex AI and Bedrock (#53416)
* fix(mistral): map tool call ids to Mistral's 9-char shape on Vertex AI and Bedrock

Mistral on Vertex AI answers 400 to any tool call id that is not 9 letters or digits, so replayed OpenAI or Anthropic ids fail there. Mistral on Bedrock Converse keeps only an id's last 9 characters, which still fails for short ids like call_abc123

Ids that are not already 9 alphanumeric characters are now hashed to a stable 9-char id, so a call and its tool reply still pair up. Direct Mistral and every other Bedrock model keep the caller's ids

* fix(mistral): map tool call ids for Vertex AI Mistral names outside the cost map and Bedrock Mantle Mistral

Vertex AI routes every model name holding mistral to its Mistral handler, so the id mapping now runs for @version names and models the cost map lacks. Bedrock Mantle maps chat tool call ids for mistral.* models

* test(mistral): check every Vertex AI Mistral name gets the body a listed Mistral model gets

A Vertex AI name outside the cost map, @version names included, now sends
the same request body as mistral-medium-3 for tool_choice, seed, a user
name, reasoning_content and content lists.

* fix(vertex_ai): send several Mistral text parts as separate parts

* fix(vertex_ai): send Mistral text parts without extra keys when a message carries an image

* fix(vertex_ai): send presence_penalty, frequency_penalty and n to Vertex AI Mistral

Vertex AI Mistral names outside the cost map used to get the Llama config,
which sent these three, and Vertex accepts all three on every Mistral model
it serves. Listed names now send them too. The direct Mistral API still
leaves them out.

A tool call id that is not a string now goes to the provider as it came,
which answers 422, where the id mapping raised a 500

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-22 21:48:55 +00:00
..
audio_speech chore(typing): clear 670 basedpyright Any errors by validating provider payloads at the boundary (#45388) 2026-10-13 15:35:23 -07:00
audio_transcription fix(audio-transcription): keep transcripts out of transcription error messages (#50137) 2026-11-05 18:07:15 -08:00
batches test: migrate phase 9 legacy llm provider tests to tests/unit 2026-09-20 08:13:11 +00:00
count_tokens test(responses): align bridged system prompt expectations (#52693) 2026-11-19 00:27:35 +00:00
files test: migrate phase 9 legacy llm provider tests to tests/unit 2026-09-20 08:13:11 +00:00
__init__.py test: migrate phase 9 legacy llm provider tests to tests/unit 2026-09-20 08:13:11 +00:00
test_mistral_chat_transformation.py fix(mistral): map tool call ids to Mistral's 9-char shape on Vertex AI and Bedrock (#53416) 2026-11-22 21:48:55 +00:00
test_mistral_completion.py test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00
test_mistral_embedding.py test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00