From d600d7a6685546f46fd97dafbec4c8c5b91a7bd2 Mon Sep 17 00:00:00 2001 From: factnn <166481866+factnn@users.noreply.github.com> Date: Sun, 21 Jun 2026 15:56:43 +0800 Subject: [PATCH] fix: also strip reasoning_content from Mistral messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #30835 — reasoning_content in assistant messages causes 422 extra_forbidden when forwarded to Mistral API. --- litellm/llms/mistral/chat/transformation.py | 2 ++ .../llms/mistral/test_mistral_chat_transformation.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/litellm/llms/mistral/chat/transformation.py b/litellm/llms/mistral/chat/transformation.py index ba44d9f2340..8daddde19de 100644 --- a/litellm/llms/mistral/chat/transformation.py +++ b/litellm/llms/mistral/chat/transformation.py @@ -272,6 +272,7 @@ class MistralConfig(OpenAIGPTConfig): m.pop("provider_specific_fields", None) m.pop("thinking_blocks", None) m.pop("cache_control", None) + m.pop("reasoning_content", None) new_messages.append(m) if is_async: @@ -306,6 +307,7 @@ class MistralConfig(OpenAIGPTConfig): m.pop("provider_specific_fields", None) m.pop("thinking_blocks", None) m.pop("cache_control", None) + m.pop("reasoning_content", None) return messages def _handle_message_with_file(self, messages: List[AllMessageValues]) -> List[AllMessageValues]: diff --git a/tests/test_litellm/llms/mistral/test_mistral_chat_transformation.py b/tests/test_litellm/llms/mistral/test_mistral_chat_transformation.py index 3b54aa18a3c..c0ed90efda0 100644 --- a/tests/test_litellm/llms/mistral/test_mistral_chat_transformation.py +++ b/tests/test_litellm/llms/mistral/test_mistral_chat_transformation.py @@ -266,6 +266,7 @@ class TestMistralReasoningSupport: "provider_specific_fields": {"foo": "bar"}, "thinking_blocks": [], "cache_control": {"type": "ephemeral"}, + "reasoning_content": "some thinking", }, ) ] @@ -278,6 +279,7 @@ class TestMistralReasoningSupport: assert "provider_specific_fields" not in msg assert "thinking_blocks" not in msg assert "cache_control" not in msg + assert "reasoning_content" not in msg def test_transform_request_magistral_with_reasoning(self): """Test transform_request method for magistral model with reasoning."""