Repository navigation
🧩 fix: Keep Text and Tool Calls From Mistral Typed Delta Chunks - #604
Open
jordanmarques wants to merge 1 commit into
Open
jordanmarques wants to merge 1 commit into
jordanmarques wants to merge 1 commit into
Conversation
jordanmarques
marked this pull request as ready for review
October 9, 2026 09:09
Mistral's Chat Completions stream sends delta.content as a list of typed chunks (thinking, text) while the model reasons. The chunk that ends the reasoning also carries the first words of the answer, and sometimes the first tool-call delta with its id and name. _streamResponseChunks skips any chunk whose content is not a string, so answers lost their first words and tool calls lost their name, which ended the run with an empty response. Flatten those chunks before the LangChain conversion: text blocks become the string content, thinking blocks become the reasoning delta. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jordanmarques
force-pushed
the
fix/mistral-typed-delta-content
branch
from
October 9, 2026 09:10
38888fa to
402ec96
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a Mistral model reasons (Mistral Large 4, or GLM 5.3 served by Mistral), its Chat Completions
stream sends
delta.contentas a list of typed chunks instead of a string:{"delta": {"content": [ {"type": "thinking", "thinking": [{"type": "text", "text": " done."}], "closed": true}, {"type": "text", "text": "A freelancer"} ]}}The chunk that closes the reasoning also carries the first words of the answer, and sometimes the
first tool-call delta, the only one with the call's
idandname._streamResponseChunksskipsevery chunk whose content is not a string (
[WARNING]: Received non-string content from OpenAI),so:
"ancer is a self-employed…");This format is Mistral's documented streaming behavior for reasoning models; only
reasoning_effort: "none"returns plain strings, and some models (GLM 5.3) refuse that value.Change
LibreChatOpenAICompletions._convertCompletionsDeltaToBaseMessageChunkflattens a listdelta.contentbefore the LangChain conversion:textblocks become the stringcontent;thinkingblocks becomedelta.reasoning, whichattachLibreChatDeltaFieldsalready maps toadditional_kwargs.reasoning_content.String content and other providers are unchanged.
Testing
src/llm/openai/mistralContentChunks.test.ts: mixed reasoning + text chunk, reasoning +tool-call chunk, reasoning-only chunk.
src/llm/openaisuite: 211 tests pass;tsc --noEmitand ESLint clean.🤖 Generated with Claude Code