Repository navigation
Conversation
Mistral's chat completions API types message.content and delta.content
as string | null | ContentChunk[]. Its reasoning models answer with a
ThinkChunk ({"type":"thinking","thinking":[TextChunk...]}) and a
TextChunk, and the stream switches from chunk arrays to plain strings
once the answer starts. Translate mode decoded content into a string,
so every such response failed with "cannot unmarshal array into Go
struct field openAIMessage.choices.message.content of type string".
Decode content as either shape: text parts become the answer, thinking
parts go to ChatDelta.ReasoningContent, other part types are ignored.
When a non-streaming reply carries a ChatDelta (tool calls or
reasoning), the delta now holds the text as well, because consumers
take the answer from the delta when one is present. Plain string
content is handled as before.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Stefan Walcz <stefan.walcz@walcz.de>
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.
Mistral's chat completions API types
message.contentanddelta.contentasstring | null | ContentChunk[](AssistantMessage / DeltaMessage inhttps://docs.mistral.ai/openapi.yaml). Reasoning models answer with a
ThinkChunk plus a TextChunk:
and, per https://docs.mistral.ai/capabilities/reasoning/, the stream sends
chunk arrays during thinking and plain strings once the answer starts.
Translate mode decoded content into a string, so every such response failed:
Reproduction: a model with
backend: cloud-proxy,proxy.mode: translate,provider: openai,upstream_url: https://api.mistral.ai/v1/chat/completionsand a Mistral reasoning model as
upstream_model; any chat request failswith the error above.
Change:
textparts become theanswer,
thinkingparts go toChatDelta.ReasoningContent, other parttypes are ignored. Requests still send content as a string.
reasoning_content.the delta now also holds the answer text, because consumers take the answer
from the delta when one is present. Plain string content is unchanged.
Tests: new Ginkgo specs in provider_openai_content_test.go with a fake
upstream returning Mistral-shaped bodies (non-streaming, tool calls,
streaming across both shapes) plus counter-checks for plain string content
and deltas.
go test ./...in backend/go/cloud-proxy passes.Docs: docs/content/operations/cloud-proxy.md (translate mode section).
Breaking changes: none for plain string content. Behaviour change: a non-streaming reply that carries tool calls or reasoning now keeps its answer text in the ChatDelta (previously dropped).
AI assistance: prepared with Claude Code (see the
Assisted-bytrailer); reviewed and signed off by me.