-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Bug description
When using Mistral's Magistral reasoning models (e.g., magistral-medium-2509), the ChatCompletionMessage.content() method throws an IllegalStateException: The content is not a string! because Magistral models return the content field as an array of content blocks instead of a plain string.
The reasoning models return a structured response with separate thinking and text blocks, but the current implementation only handles string content.
Environment
- Spring AI version: 1.0.x / 1.1.0-Mx
- Java version: 21
- Mistral model: magistral-medium-latest (magistral-medium-2509)
Steps to reproduce
- Configure Spring AI with Mistral AI provider
- Use a Magistral reasoning model (magistral-medium-latest or magistral-small latest)
- Send any chat completion request
- Call .content() on the response message
Expected behavior
The content() method should extract and return the final answer from the text content block, ignoring the thinking block.
Minimal Complete Reproducible example
{
"choices": [
{
"message": {
"role": "assistant",
"content": [
{
"type": "thinking",
"thinking": [
{
"type": "text",
"text": "Reasoning traces..."
}
]
},
{
"type": "text",
"text": "Final answer..."
}
]
}
}
]
}Leads to:
Caused by: java.lang.IllegalStateException: The content is not a string!
org.springframework.ai.mistralai.api.MistralAiApi$ChatCompletionMessage.content(MistralAiApi.java:~1425)