openclaw - ✅(Solved) Fix MiniMax API: tool_call id mismatch causes 400 error (2013) [1 pull requests, 4 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63564Fetched 2026-04-10 03:42:47
View on GitHub
Comments
4
Participants
3
Timeline
6
Reactions
0
Author
Timeline (top)
commented ×4cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #63597: fix(minimax): normalize baseUrl to Anthropic path when api is anthropic-messages

Description (problem / solution / changelog)

Summary

Fixes #63564 — MiniMax API tool_call ID mismatch (error 2013) when user overrides baseUrl.

Root cause: When a user sets models.providers.minimax.baseUrl to the OpenAI-compatible path (e.g. https://api.minimaxi.com/v1) while keeping the default api: "anthropic-messages" transport, the Anthropic SDK client hits the wrong MiniMax endpoint. That endpoint returns OpenAI-format tool_calls with call_* IDs instead of Anthropic tool_use blocks, causing tool_call_id mismatch error 2013.

The existing resolveMinimaxCatalogBaseUrl helper (which appends /anthropic when missing) only runs for the MINIMAX_API_HOST env var. It does not run for user config file overrides, because mergeImplicitProviderConfig spreads {...implicit, ...existing} — user config fields always win without re-normalization.

Fix: Add a normalizeConfig hook to both minimax and minimax-portal provider registrations. The hook:

  • Rewrites any non-/anthropic baseUrl to use the /anthropic path
  • Is a no-op when baseUrl already ends in /anthropic
  • Is a no-op for explicit api: "openai-completions" configs (leave those untouched)
  • Is a no-op for undefined/unparseable URLs

Also exports normalizeMinimaxAnthropicBaseUrl from api.ts for external reuse.

Test plan

  • pnpm test extensions/minimax/index.test.ts — all 15 tests pass (includes new normalizeConfig coverage for both providers and parametrized unit tests for normalizeMinimaxAnthropicBaseUrl)
  • pnpm check — 0 warnings, 0 errors

🤖 Generated with Claude Code

Changed files

Code Example

invalid params, tool call and result not match (2013)

---

{
  "model": "MiniMax-M2.7",
  "messages": [
    {"role": "user", "content": "What is 2+2?"},
    {"role": "assistant", "content": "Let me calculate that.", "tool_calls": [{"id": "call_abc123", "type": "function", "function": {"name": "calculator", "arguments": "{}"}}]}
  ],
  "tools": [{"type": "function", "function": {"name": "calculator", "description": "A calculator", "parameters": {"type": "object", "properties": {}}}}],
  "max_tokens": 50
}

---

{
  "minimax": {
    "baseUrl": "https://api.minimaxi.com/v1",
    "apiKey": "sk-...",
    "models": [{"id": "MiniMax-M2.7", "contextWindow": 1000000}]
  }
}
RAW_BUFFERClick to expand / collapse

问题描述

当使用 MiniMax (MiniMax-M2.7) 模型时,OpenClaw 在执行工具调用后发送 tool_call 结果时遇到 400 错误。

错误信息

invalid params, tool call and result not match (2013)

复现步骤

  1. 配置 OpenClaw 使用 MiniMax-M2.7 作为主模型或 fallback 模型
  2. 让 AI 执行任何需要工具调用的操作(如读取文件、执行命令等)
  3. 当模型返回 tool_calls 后,OpenClaw 发送 tool 结果时触发此错误

技术分析

通过直接调用 MiniMax API 测试发现:

失败的请求格式:

{
  "model": "MiniMax-M2.7",
  "messages": [
    {"role": "user", "content": "What is 2+2?"},
    {"role": "assistant", "content": "Let me calculate that.", "tool_calls": [{"id": "call_abc123", "type": "function", "function": {"name": "calculator", "arguments": "{}"}}]}
  ],
  "tools": [{"type": "function", "function": {"name": "calculator", "description": "A calculator", "parameters": {"type": "object", "properties": {}}}}],
  "max_tokens": 50
}

错误原因: MiniMax API 要求:当上一条 assistant 消息包含 tool_calls 时,发送 tool 结果时必须使用完全相同的 tool_call_id。OpenClaw 可能在发送 tool 结果时生成了新的 id 或格式不匹配。

成功的替代格式: 如果 assistant 消息中没有 tool_calls,直接调用工具则成功。

环境信息

  • OpenClaw 版本: 2026.4.1
  • Node.js 版本: 22.22.1
  • macOS

临时解决方案

从 fallback 列表中移除 MiniMax,仅使用其他兼容的 API 提供商(如 SiliconFlow/DeepSeek)处理工具调用。

相关配置

{
  "minimax": {
    "baseUrl": "https://api.minimaxi.com/v1",
    "apiKey": "sk-...",
    "models": [{"id": "MiniMax-M2.7", "contextWindow": 1000000}]
  }
}

请求

希望 OpenClaw 能修复此兼容性问题,或在文档中明确说明 MiniMax 的工具调用限制。

extent analysis

TL;DR

OpenClaw needs to ensure that the tool_call_id sent in the tool result matches the one received in the tool_calls message from the MiniMax model to fix the 400 error.

Guidance

  • Verify that OpenClaw is correctly handling the tool_call_id by checking the request and response formats for tool calls and results.
  • Ensure that the tool_call_id is not being regenerated or modified when sending the tool result, which could cause the mismatch.
  • Review the MiniMax API documentation to confirm the requirements for tool_call_id consistency.
  • Consider implementing a workaround where OpenClaw stores the original tool_call_id from the model's response and uses it when sending the tool result.

Example

// Example of a tool call message with a specific id
{
  "role": "assistant",
  "content": "Let me calculate that.",
  "tool_calls": [{"id": "call_abc123", "type": "function", "function": {"name": "calculator", "arguments": "{}"}}]
}

// Ensure the tool result uses the same id
{
  "tool": {
    "id": "call_abc123",
    "type": "function",
    "function": {"name": "calculator", "result": "4"}
  }
}

Notes

The issue seems specific to the interaction between OpenClaw and the MiniMax-M2.7 model, particularly with tool calls and results. Ensuring the tool_call_id consistency is crucial for resolving the 400 error.

Recommendation

Apply workaround: Modify OpenClaw to store and reuse the original tool_call_id from the model's response when sending the tool result, to maintain consistency and comply with the MiniMax API requirements.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING