mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(mistral): strip reasoning_content from assistant input messages
When an assistant message includes `reasoning_content` (added by litellm when parsing a Mistral thinking response), and that message is replayed in subsequent requests, Mistral rejects the whole request with 422 `extra_forbidden` because `reasoning_content` is not a valid input field. Fix: in `_transform_messages`, pop `reasoning_content` from assistant messages before forwarding to the Mistral API. This is consistent with the existing `strip_none_values_from_message` call that already prevents similar `extra_forbidden` errors. Fixes #30835.
This commit is contained in:
parent
dcf1b445e6
commit
5c4fe9ca58
1 changed files with 3 additions and 0 deletions
|
|
@ -268,6 +268,9 @@ class MistralConfig(OpenAIGPTConfig):
|
|||
m = MistralConfig._handle_tool_call_message(m)
|
||||
if MistralConfig._is_empty_assistant_message(m):
|
||||
continue
|
||||
# Strip reasoning_content from assistant messages — Mistral rejects it as input (extra_forbidden)
|
||||
if m.get("role") == "assistant":
|
||||
m.pop("reasoning_content", None)
|
||||
m = strip_none_values_from_message(m) # prevents 'extra_forbidden' error
|
||||
new_messages.append(m)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue