Repository navigation
fix(chat): read Mistral's list-shaped content (thinking + text parts) - #204
Open
Nicolas Werner (nicolas-werner) wants to merge 1 commit into
Open
Nicolas Werner (nicolas-werner) wants to merge 1 commit into
Nicolas Werner (nicolas-werner) wants to merge 1 commit into
Conversation
Mistral reasoning models such as mistral-large-4 stream `delta.content` as a list of parts when reasoning is on: text parts, and thinking parts whose text sits one level deeper. The Chat Completions reader concatenated `content` as a string, so every Mistral Large 4 run crashed with "TypeError: can only concatenate str (not "list") to str". Split such content: text parts go to the reply, thinking parts to the reasoning, the same way `reasoning_content` from other services is shown. String content is handled as before. The non-streaming reply gets the same treatment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nicolas Werner (nicolas-werner)
requested a review
from Zezi Zeng (ClarenceStark)
as a code owner
December 6, 2026 13:30
|
Thanks for the pull request! A few friendly reminders based on the files changed:
(This comment updates automatically when you edit the PR description or push new commits.) |
Author
|
@microsoft-github-policy-service agree |
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.
Linked issue
None: a small bug fix (a crash on one provider), so no prior issue.
What changed (Before / After)
openai-chatathttps://api.mistral.ai/v1andmistral-large-4, every run crashed on the firstresponse with
TypeError: can only concatenate str (not "list") to strinChat.read_stream. When reasoning is on,Mistral streams
delta.contentas a list of parts ({"type": "thinking", "thinking": [{"type": "text", ...}]}and{"type": "text", ...}), and the reader assumed a string.freehand check mistralfailed the same way.the same way as
reasoning_contentfrom other services. String content is handled as before.from_json(a servicethat ignores
stream) gets the same treatment.Nothing the model sees changes. Mistral is not an interleaved-reasoning host, so the reasoning is still not sent back.
Visual proof (UI / TUI / Web / Desktop / export changes)
Backend-only. Terminal output from a live run after the fix:
How you verified it
test_mistral_list_content_splits_thinking_from_textintests/test_provider_conformance.py(streamed thinking and text parts mixed with a plain string delta, plus
from_json). It fails without the fix.uv run pyflakes src tests .github/scriptsprints nothing.tests/test_provider_conformance.py,tests/test_providers.py,tests/test_provider_http.py: 194 passed.ci.py parallel --shards 3 -- pytest -q --suite=core) passed locally.src/freehand/runtime/passes.freehand check mistralwithmistral-large-4passed several runs, and an interactive headless run showed thethinking in the reasoning display and the answer as text.
mistral-small-2603(no reasoning field) still passes.AI disclosure & checklist
uv run pyflakes src tests .github/scriptsprints nothing and relevant tests pass locally (full suite runs in CI)CHANGELOG.mduntouched (maintainers update it at release time)src/freehand/runtime/still uses only the standard library and imports on Python 3.9🤖 Generated with Claude Code