Skip to content

Tool Call ID Format Incompatible with Mistral API: "must be a-z, A-Z, 0-9, with a length of 9" #1680

@anschmieg

Description

@anschmieg

When using the mistral/mistral-large-latest model (and likely other recent Mistral models) as a provider, all tool calls are rejected by the Mistral API unless the tool call ID:

  • consists only of a-z, A-Z, or 0-9 ( i.e. no underscores, dashes, or "call_" prefix)
  • and is exactly 9 characters long.

Currently, OpenCode (or some MCP server used? I don't think so, I didn't see a MCP call message) generates tool call IDs like call_PTLP8xhu3uwZk4l3nlnrrJha, which both violate the allowed character set and are too long.

Error Message

AI_APICallError: Tool call id was call_PTLP8xhu3uwZk4l3nlnrrJha but must be a-z, A-Z, 0-9, with a length of 9.

Steps to Reproduce

  1. Configure a mode in opencode.jsonc to use "model": "mistral/mistral-large-latest" (or any tool-calling Mistral model).
  2. Trigger a flow that invokes tool calling (e.g. filesystem, code-analysis, etc).
  3. Hopefully observe the above error.

Expected Behavior

Tool call IDs should comply with the current [Mistral API tool call requirements](documented examples) (a-z, A-Z, 0-9, exactly 9 characters).
The agent should be able to successfully call tools with Mistral models.

Actual Behavior

All my tool calls to Mistral were rejected due to invalid tool call IDs. This breaks all tool-dependent workflows with Mistral models.

Suggested Fix

  • Update tool call ID generation logic:
    • Generate IDs using only [a-zA-Z0-9], length exactly 9 (no prefix/suffix).
    • Remove any default "call_" prefix for Mistral API calls.
    • If required, limit this to Mistral models, potentially as a tool ID replacement layer.

Environment

  • OpenCode version: v0.3.133
  • Mistral provider: mistral/mistral-large-latest
  • System: macOS 26 Public Beta 1

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