anomalyco / anomalyco/opencode

[Bug] Mistral provider (zai-glm-5-2) fails with AI_TypeValidationError on streamed tool calls (@ai-sdk/mistral dependency update needed)

Open
#49,139 2 comments 2 reactions 1 assignee View on GitHub

@neriousy is already working on this.

Since Sep 15, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description
Environment
  • OpenCode Version: 1.18.29
  • OS: CachyOS (Arch Linux)
  • Model / Provider: Mistral (mistral/zai-glm-5-2)
Problem Description

When using Mistral models (specifically zai-glm-5-2) with tool calling enabled, streaming responses crash with an AI_TypeValidationError.

The error trace indicates that OpenCode's internal @ai-sdk/mistral adapter expects an id field on every streamed tool-call chunk, whereas incremental continuation chunks only stream partial arguments without repeating the id.

Error Log
AI_TypeValidationError: Type validation failed: 
Value: {"id":"34ab1513a87f422fbc31733708620b96","object":"chat.completion.chunk","created":1789112573,"model":"zai-glm-5-2","choices":[{"index":0,"delta":{"tool_calls":[{"type":"function","function":{"name":"","arguments":"\", \"url\": \"https"},"index":0}],"index":0,"content":""},"finish_reason":null,"logprobs":null}]}.

Error message: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": ["choices", 0, "delta", "tool_calls", 0, "id"],
    "message": "Invalid input: expected string, received undefined"
  }
]
Plugins

No response

OpenCode version

1.18.29

Steps to reproduce
  1. Configure OpenCode to use native Mistral API with a valid Mistral API key.
  2. Select the mistral/zai-glm-5-2 model.
  3. Send a prompt that requires OpenCode to execute a tool call (e.g., "Read the contents of package.json in the current directory" or a WebFetch prompt).
  4. Observe the stream failing immediately when the tool call starts, throwing TypeValidationError.
Screenshot and/or share link

https://opncd.ai/share/JQEsOcbk

Image
Operating System

CachyOS (Arch Linux)

Terminal

xterm-kitty

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.