Skip to content

Migrate Mistral AI chat model to message parts - #7145

Open
dimitarproynov wants to merge 1 commit into
spring-projects:mainfrom
dimitarproynov:dimitarproynov/mistral-use-message-parts
Open

dimitarproynov wants to merge 1 commit into
spring-projects:mainfrom
dimitarproynov:dimitarproynov/mistral-use-message-parts

Conversation

@dimitarproynov

Copy link
Copy Markdown
Contributor

MistralAiChatModel now builds the assistant message of each choice from ordered message parts. Mistral returns the content as an ordered list of chunks: a thinking chunk becomes a ReasoningPart with the mistral_ai provider attribute and its signature, if any, as an opaque payload; a text chunk becomes a TextPart; and a reference or image chunk becomes an UnknownPart holding the chunk as JSON. The tool calls, which Mistral returns in a separate field, follow as ToolCallParts. Streamed parts are stamped with their index per choice, so the MessageAggregator merges each run of deltas into one part.

An assistant message is replayed as content chunks in part order. Mistral recommends sending the thinking of its reasoning models back, so a Mistral ReasoningPart goes back as a thinking chunk with its signature, while reasoning from another provider is not sent. A message without reasoning parts, such as one built by an earlier version, falls back to the thinking_content metadata, as OpenAiChatModel does with its reasoning metadata. User message parts are sent in order, so text and images can interleave.

MistralAiApi.ThinkChunk gains the signature field of the API, with a constructor that keeps the previous components. getText() now joins the text chunks without the line separator, which split the text around a citation. Streamed chunks always carry the response id, and THINKING_CONTENT_METADATA is deprecated in favor of getReasoning().

Update the Mistral AI reference documentation and the upgrade notes.

Build, unit and integration tests pass.

MistralAiChatModel now builds the assistant message of each choice
from ordered message parts. Mistral returns the content as an ordered
list of chunks: a thinking chunk becomes a ReasoningPart with the
mistral_ai provider attribute and its signature, if any, as an opaque
payload; a text chunk becomes a TextPart; and a reference or image
chunk becomes an UnknownPart holding the chunk as JSON. The tool
calls, which Mistral returns in a separate field, follow as
ToolCallParts. Streamed parts are stamped with their index per choice,
so the MessageAggregator merges each run of deltas into one part.

An assistant message is replayed as content chunks in part order.
Mistral recommends sending the thinking of its reasoning models back,
so a Mistral ReasoningPart goes back as a thinking chunk with its
signature, while reasoning from another provider is not sent. A
message without reasoning parts, such as one built by an earlier
version, falls back to the thinking_content metadata, as
OpenAiChatModel does with its reasoning metadata. User message parts
are sent in order, so text and images can interleave.

MistralAiApi.ThinkChunk gains the signature field of the API, with a
constructor that keeps the previous components. getText() now joins
the text chunks without the line separator, which split the text
around a citation. Streamed chunks always carry the response id, and
THINKING_CONTENT_METADATA is deprecated in favor of getReasoning().

Update the Mistral AI reference documentation and the upgrade notes.

Signed-off-by: Dimitar Proynov <dimitar.proynov@broadcom.com>
@dimitarproynov dimitarproynov added this to the 2.1.0-RC1 milestone Oct 13, 2026
@ilayaperumalg ilayaperumalg self-assigned this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants