From f24d70ec8e5c60609c47ea1041e86b3e48f5ee94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=8C=AB=E5=AD=90?= <1811866786@qq.com> Date: Sat, 14 Feb 2026 03:44:36 +0800 Subject: [PATCH] fix(providers): switch MiniMax API-key provider to anthropic-messages (#15297) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 0e7f84a2a103135221b73e2c3f300790206fc6f4 Co-authored-by: lailoo <20536249+lailoo@users.noreply.github.com> Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com> Reviewed-by: @gumadeiras --- CHANGELOG.md | 2 ++ .../models-config.providers.minimax.test.ts | 26 +++++++++++++++++++ src/agents/models-config.providers.ts | 5 ++-- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/agents/models-config.providers.minimax.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 4898aa7e400..9e9ff388b14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,8 @@ Docs: https://docs.openclaw.ai - Process/Exec: avoid shell execution for `.exe` commands on Windows so env overrides work reliably in `runCommandWithTimeout`. Thanks @thewilloftheshadow. - Web tools/web_fetch: prefer `text/markdown` responses for Cloudflare Markdown for Agents, add `cf-markdown` extraction for markdown bodies, and redact fetched URLs in `x-markdown-tokens` debug logs to avoid leaking raw paths/query params. (#15376) Thanks @Yaxuan42. - Config: keep legacy audio transcription migration strict by rejecting non-string/unsafe command tokens while still migrating valid custom script executables. (#5042) Thanks @shayan919293. +- Status/Sessions: stop clamping derived `totalTokens` to context-window size, keep prompt-token snapshots wired through session accounting, and surface context usage as unknown when fresh snapshot data is missing to avoid false 100% reports. (#15114) Thanks @echoVic. +- Providers/MiniMax: switch implicit MiniMax API-key provider from `openai-completions` to `anthropic-messages` with the correct Anthropic-compatible base URL, fixing `invalid role: developer (2013)` errors on MiniMax M2.5. (#15275) ## 2026.2.12 diff --git a/src/agents/models-config.providers.minimax.test.ts b/src/agents/models-config.providers.minimax.test.ts new file mode 100644 index 00000000000..7832e483bce --- /dev/null +++ b/src/agents/models-config.providers.minimax.test.ts @@ -0,0 +1,26 @@ +import { mkdtempSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; +import { resolveImplicitProviders } from "./models-config.providers.js"; + +describe("MiniMax implicit provider (#15275)", () => { + it("should use anthropic-messages API for API-key provider", async () => { + const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-")); + const previous = process.env.MINIMAX_API_KEY; + process.env.MINIMAX_API_KEY = "test-key"; + + try { + const providers = await resolveImplicitProviders({ agentDir }); + expect(providers?.minimax).toBeDefined(); + expect(providers?.minimax?.api).toBe("anthropic-messages"); + expect(providers?.minimax?.baseUrl).toBe("https://api.minimax.io/anthropic"); + } finally { + if (previous === undefined) { + delete process.env.MINIMAX_API_KEY; + } else { + process.env.MINIMAX_API_KEY = previous; + } + } + }); +}); diff --git a/src/agents/models-config.providers.ts b/src/agents/models-config.providers.ts index ee63b9d4483..aa6adfd434a 100644 --- a/src/agents/models-config.providers.ts +++ b/src/agents/models-config.providers.ts @@ -32,7 +32,6 @@ import { discoverVeniceModels, VENICE_BASE_URL } from "./venice-models.js"; type ModelsConfig = NonNullable; export type ProviderConfig = NonNullable[string]; -const MINIMAX_API_BASE_URL = "https://api.minimax.chat/v1"; const MINIMAX_PORTAL_BASE_URL = "https://api.minimax.io/anthropic"; const MINIMAX_DEFAULT_MODEL_ID = "MiniMax-M2.1"; const MINIMAX_DEFAULT_VISION_MODEL_ID = "MiniMax-VL-01"; @@ -380,8 +379,8 @@ export function normalizeProviders(params: { function buildMinimaxProvider(): ProviderConfig { return { - baseUrl: MINIMAX_API_BASE_URL, - api: "openai-completions", + baseUrl: MINIMAX_PORTAL_BASE_URL, + api: "anthropic-messages", models: [ { id: MINIMAX_DEFAULT_MODEL_ID,