Skip to content

Tool calls throw errors for Mistral's GLM-5.2 #43199

Description

@KPhi

Description

Recently, Mistral has started hosting third-party open models from other providers, starting with GLM-5.2. When manually adding this model to the mistral provider, text responses work fine, but as soon as tools are called, the response validation throws an error:

AI_TypeValidationError: Type validation failed: Value: {"id":"0d56b68eea734ccd983ea66a85ad7781","object":"chat.completion.chunk","created":1787036970,"model":"zai-glm-5-2","choices":[{"index":0,"delta":{"tool_calls":[{"type":"function","function":{"name":"","arguments":"C:\\workspace"},"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"
  }
] (cause: [
  {
    "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.18

Steps to reproduce

  1. Add Mistral manually to the plugins section in the configuration and define the zai-glm-5-2 model there (see below for example).
  2. Start a session and select the new model
  3. See an error as soon as a tool is called

opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "mistral": {
      "name": "Mistral (custom)",
      "npm": "@ai-sdk/mistral",
      "models": {
        "zai-glm-5-2": {
          "name": "GLM-5.2",
          "attachment": true,
          "reasoning": true,
          "temperature": true,
          "tool_call": true,
          "limit": {
            "context": 1000000,
            "output": 131072
          },
          "modalities": {
            "input": [
              "text"
            ],
            "output": [
              "text"
            ]
          },
          "variants": {
            "high": {
              "reasoningEffort": "high"
            }
          }
        },
      }
    }
  }
}

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Activity

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

Metadata

Metadata

Assignees

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