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
@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
- Configure OpenCode to use native Mistral API with a valid Mistral API key.
- Select the
mistral/zai-glm-5-2model. - 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).
- Observe the stream failing immediately when the tool call starts, throwing
TypeValidationError.
Screenshot and/or share link
https://opncd.ai/share/JQEsOcbk
Operating System
CachyOS (Arch Linux)
Terminal
xterm-kitty
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.