Skip to content

Conversation

@dskarzh
Copy link

@dskarzh dskarzh commented Dec 2, 2025

Issue:

Mistral AI reasoning models (Magistral) return content as an array of content objects, whereas non-reasoning models return it as a string. LangChain4j only handled string responses, causing deserialization failures with reasoning models.

Changes:

  • Add MistralAiThinkingContent and MistralAiReferenceContent classes for new content types
  • Add polymorphic deserialization support to MistralAiMessageContent via @JsonTypeInfo/@JsonSubTypes
  • Update MistralAiChatMessageBuilder.content() to handle both string and array (reasoning models) formats
  • Update MistralAiChatMessage.asText() to extract text content from multi-part responses

@dskarzh dskarzh changed the title MistralAI : fix responses from reasoning models Mistral AI : fix responses from reasoning models Dec 2, 2025
@ViacheslavKlimov ViacheslavKlimov merged commit 32904d5 into main Dec 2, 2025
3 of 8 checks passed
@ViacheslavKlimov ViacheslavKlimov deleted the mistral/fix-reasoning-responses branch December 2, 2025 13:03
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.

3 participants