Skip to content

fix(mistral): bump @ai-sdk/mistral to 3.0.64 to unbreak streamed tool calls - #49689

Closed
TimoStolz wants to merge 1 commit into
anomalyco:devfrom
TimoStolz:fix/mistral-toolcall-stream
Closed

TimoStolz wants to merge 1 commit into
anomalyco:devfrom
TimoStolz:fix/mistral-toolcall-stream

Conversation

@TimoStolz

@TimoStolz TimoStolz commented Sep 18, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #49692

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Bumps @ai-sdk/mistral from 3.0.51 to 3.0.64 so that streamed tool calls work on the GLM models Mistral relays (zai-glm-5, zai-glm-5-2, zai-glm-5-3, zai-glm-latest). Today they abort on the first tool call.

The pinned 3.0.51 declares id: z.string() for every entry in a tool_calls delta. That is stricter than the wire format: Mistral sends id and function.name only in the first delta for a given index, and continuation chunks carry arguments fragments alone — clients are meant to accumulate by index. So the chunk that continues a tool call fails validation, the arguments never get assembled, and the tool is invoked with an empty object.

This only surfaces on the relayed GLM models because Mistral's own models don't fragment tool-call arguments — they return the whole tool call in one chunk, id included, so the continuation path is never taken. That is also why the bump is safe for them: their behaviour doesn't change.

3.0.59 fixed this upstream by relaxing the schema to id: z.string().nullish() and routing deltas through StreamingToolCallTracker, which falls back to toolCallsByIndex when the id is absent. I picked 3.0.64 as the latest release on the 3.x line this repo already tracks; 3.0.59 is the minimum that works.

The lockfile change is the one resolution entry plus its dependency pins (@ai-sdk/[email protected], which is where the tracker lives).

How did you verify your code works?

Reproduced the failure on 1.18.29, then pinned the new version locally via a config override ("npm": "@ai-sdk/[email protected]"), which exercises the same code path as this diff:

$ opencode run --model mistral/zai-glm-5-3 "read README.md, CONTEXT.md and list packages/, then summarize"
> build · zai-glm-5-3
→ Read packages
→ Read README.md
→ Read CONTEXT.md
BMT is a platform for behavioral-economics studies: …

Several consecutive tool calls, clean finish. Same check on zai-glm-5-2. I also confirmed against the raw SSE stream that mistral-large-latest, mistral-medium-latest, magistral-medium-latest and codestral-latest emit tool calls in a single chunk with id set, so they never hit the changed path.

Screenshots / recordings

n/a — not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

… calls

@ai-sdk/mistral 3.0.51 requires a tool_call "id" in every streaming chunk.
Mistral only sends it in the first delta per index, so any model that
fragments tool-call arguments across chunks fails on the first tool call.
This makes the zai-glm-* relay models unusable in opencode.

Fixed upstream in @ai-sdk/mistral 3.0.59 via StreamingToolCallTracker,
which falls back to accumulating by index when the id is absent.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@blackcodefr

Copy link
Copy Markdown

This fix works when done locally in the config file.

"@ai-sdk/google-vertex": "4.0.181",
"@ai-sdk/groq": "3.0.31",
"@ai-sdk/mistral": "3.0.51",
"@ai-sdk/mistral": "3.0.64",

@jope35 jope35 Sep 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jope35

jope35 commented Sep 22, 2026 •

Copy link
Copy Markdown

thanks @TimoStolz for driving this, looking forward to the merge of this PR!

@blackcodefr

Copy link
Copy Markdown

Unfortunately, this version doesn't support prompt caching. See #50748 for more details.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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 GLM relay models fail on tool calls (missing tool_call id in continuation chunks)

4 participants