Skip to content

fix: unmarshal Mistral array-typed chat completion content - #2979

Open
vshalpnjabi wants to merge 2 commits into
theagentrouter:mainfrom
vshalpnjabi:fix/mistral-array-content-2974
Open

vshalpnjabi wants to merge 2 commits into
theagentrouter:mainfrom
vshalpnjabi:fix/mistral-array-content-2974

Conversation

@vshalpnjabi

Copy link
Copy Markdown

Description

This change makes OpenAI-compatible chat completion response unmarshalling accept Mistral reasoning-model payloads where choices[].message.content is an array of typed parts instead of a string. Text parts are mapped to content and thinking parts are mapped to reasoning_content, matching the existing reasoning_content field on the response message. The OpenAI-to-OpenAI translator can now record usage and spans for these responses instead of returning HTTP 500.

AI-assisted; I reviewed the full diff and ran the tests myself.

Related Issues/PRs (if applicable)

Fixes #2974

Special notes for reviewers (if applicable)

The request-side thinking parameter mentioned in the issue is unchanged. Streaming deltas that use array content are also unchanged, as are unknown part types (they are skipped).

Checks run:

  • go test ./internal/apischema/openai/ -count=1 -run TestChatCompletionResponse_mistralArrayContent (fails before the fix, passes after)
  • go test ./internal/apischema/openai/ ./internal/translator/ -count=1
  • make precommit

Mistral reasoning models return choices[].message.content as an
array of typed parts instead of a string. The OpenAI-compatible
response path now accepts that shape, mapping text parts to
content and thinking parts to reasoning_content.

Signed-off-by: Vishal Punjabi <10079537+vshalpnjabi@users.noreply.github.com>
@vshalpnjabi
vshalpnjabi requested a review from a team as a code owner November 4, 2026 15:51
@netlify

netlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for theagentrouter canceled.

Name Link
🔨 Latest commit 41973ac
🔍 Latest deploy log https://app.netlify.com/projects/theagentrouter/deploys/6aee095d79cee9020f7029fa

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.

Mistral reasoning models: extproc fails to unmarshal array-typed message.content (thinking chunks)

1 participant