Skip to content

Mistral GLM relay models fail on tool calls (missing tool_call id in continuation chunks) #49692

Closed as not planned

Description

@TimoStolz

Description

Tool calls fail for every GLM model that Mistral relays (zai-glm-5, zai-glm-5-2, zai-glm-5-3, zai-glm-latest). The first tool call aborts:

✗ Read failed
Error: The read tool was called with invalid arguments:
  SchemaError(Missing key at ["filePath"]).

Error: Type validation failed ...
  "path": ["choices",0,"delta","tool_calls",0,"id"],
  "message": "Invalid input: expected string, received undefined"

The pinned @ai-sdk/mistral (3.0.51) declares id: z.string() for every entry in a tool_calls delta. Mistral sends id and function.name only in the first delta for a given index; continuation chunks carry arguments fragments alone and are meant to be accumulated by index. So the continuation chunk fails validation, the arguments are never assembled, and the tool gets called with an empty object.

Mistral's own models are unaffected because they don't fragment tool-call arguments — the whole tool call arrives in one chunk with id set, so the continuation path is never taken.

@ai-sdk/mistral 3.0.59 fixed this upstream (schema relaxed to id: z.string().nullish(), deltas routed through StreamingToolCallTracker, which falls back to accumulating by index). Bumping the pin is enough; I opened #49689 for that.

Plugins

None.

OpenCode version

1.18.29

Steps to reproduce

  1. opencode auth login with a Mistral API key
  2. Add zai-glm-5-3 under the mistral provider in opencode.json
  3. opencode run --model mistral/zai-glm-5-3 "read package.json and name the repo"

The missing id is visible in the raw stream:

curl -s https://api.mistral.ai/v1/chat/completions \
  -H "Authorization: Bearer $MISTRAL_API_KEY" -H 'Content-Type: application/json' \
  -d '{"model":"zai-glm-5-3","stream":true,
       "messages":[{"role":"user","content":"Read the file README.md"}],
       "tools":[{"type":"function","function":{"name":"read",
         "parameters":{"type":"object","properties":{"filePath":{"type":"string"}},
                       "required":["filePath"]}}}]}' \
  | grep -o '"tool_calls":.\{0,90\}'

Two chunks come back, and only the first carries an id. The same request against mistral-large-latest returns a single chunk with id present.

Screenshot and/or share link

n/a — terminal output is quoted above.

Operating System

Arch Linux (kernel 6.18.51)

Terminal

Ghostty

Activity

  1. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions