Skip to content

minimax: disable tool call ID sanitization for Anthropic-compatible API - #65371

Closed
sebykrueger wants to merge 2 commits into
openclaw:mainfrom
sebykrueger:fix/minimax-tool-call-id-passthrough
Closed

sebykrueger wants to merge 2 commits into
openclaw:mainfrom
sebykrueger:fix/minimax-tool-call-id-passthrough

Conversation

@sebykrueger

@sebykrueger sebykrueger commented Apr 12, 2026 •

Copy link
Copy Markdown

Summary

  • MiniMax's Anthropic-compatible API generates its own tool call IDs and rejects tool results if the echoed ID doesn't match exactly (error 2013: "tool result's tool id not found")
  • The default buildStrictAnthropicReplayPolicy sets sanitizeToolCallIds: true with toolCallIdMode: "strict", which rewrites IDs and breaks the roundtrip
  • Overrides buildReplayPolicy for both minimax and minimax-portal providers to set sanitizeToolCallIds: false when modelApi is anthropic-messages
  • OpenAI-compatible paths (openai-completions) keep sanitization unchanged

Related issues

Test plan

  • pnpm test extensions/minimax/index.test.ts — 6/6 pass (updated expectation for sanitizeToolCallIds: false)
  • pnpm build passes
  • Manual: MiniMax M2.7 can execute tool calls (browser, web_search, exec) without error 2013

@greptile-apps

greptile-apps Bot commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Disables tool call ID sanitization on MiniMax's Anthropic-compatible API path (modelApi === \"anthropic-messages\") for both minimax and minimax-portal providers, fixing error 2013 when MiniMax rejects echoed IDs it generated itself. The logic is correct — the runtime gates sanitization on sanitizeToolCallIds && toolCallIdMode, so the leftover toolCallIdMode: \"strict\" in the spread result is harmless.

Confidence Score: 5/5

Safe to merge; the fix is correct and all remaining findings are P2 style suggestions.

The sanitization gate at the call site (sanitizeToolCallIds && toolCallIdMode) ensures the leftover toolCallIdMode: "strict" is inert when sanitizeToolCallIds is false. Both provider registrations are updated. Only P2 concerns remain: duplicated logic that could be a shared helper, and a missing test for the portal + anthropic-messages combination.

No files require special attention.

Comments Outside Diff (1)

  1. extensions/minimax/index.test.ts, line 78-90 (link)

    P2 Missing minimax-portal + anthropic-messages test case

    The test here only exercises minimax-portal with openai-completions, verifying that sanitizeToolCallIds: true is preserved on that path. The new buildReplayPolicy override on minimax-portal for anthropic-messages (setting sanitizeToolCallIds: false) has no coverage — a typo or copy-paste error in that block would go undetected. A second expectation like:

    expect(
      portalProvider.buildReplayPolicy?.({
        provider: "minimax-portal",
        modelApi: "anthropic-messages",
        modelId: "MiniMax-M2.7",
      } as never),
    ).toMatchObject({
      sanitizeMode: "full",
      sanitizeToolCallIds: false,
      preserveSignatures: true,
      validateAnthropicTurns: true,
    });

    would close that gap.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: extensions/minimax/index.test.ts
    Line: 78-90
    
    Comment:
    **Missing `minimax-portal` + `anthropic-messages` test case**
    
    The test here only exercises `minimax-portal` with `openai-completions`, verifying that `sanitizeToolCallIds: true` is preserved on that path. The new `buildReplayPolicy` override on `minimax-portal` for `anthropic-messages` (setting `sanitizeToolCallIds: false`) has no coverage — a typo or copy-paste error in that block would go undetected. A second expectation like:
    
    ```ts
    expect(
      portalProvider.buildReplayPolicy?.({
        provider: "minimax-portal",
        modelApi: "anthropic-messages",
        modelId: "MiniMax-M2.7",
      } as never),
    ).toMatchObject({
      sanitizeMode: "full",
      sanitizeToolCallIds: false,
      preserveSignatures: true,
      validateAnthropicTurns: true,
    });
    ```
    
    would close that gap.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/minimax/provider-registration.ts
Line: 247-256

Comment:
**Duplicated `buildReplayPolicy` override block**

The same 13-line block appears verbatim for both `minimax` and `minimax-portal`. The `extensions/CLAUDE.md` guide says: "If two bundled providers share the same replay policy shape … stop copying the logic. Extract one shared helper and migrate both call sites in the same change." Consider extracting this into a module-level helper, e.g.:

```ts
function buildMinimaxAnthropicReplayPolicy(ctx: ProviderReplayPolicyContext) {
  const base = HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS.buildReplayPolicy?.(ctx);
  if (!base) return base;
  if (ctx.modelApi === "anthropic-messages") {
    return { ...base, sanitizeToolCallIds: false };
  }
  return base;
}
```

and reference it in both provider registrations as `buildReplayPolicy: buildMinimaxAnthropicReplayPolicy`.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: extensions/minimax/index.test.ts
Line: 78-90

Comment:
**Missing `minimax-portal` + `anthropic-messages` test case**

The test here only exercises `minimax-portal` with `openai-completions`, verifying that `sanitizeToolCallIds: true` is preserved on that path. The new `buildReplayPolicy` override on `minimax-portal` for `anthropic-messages` (setting `sanitizeToolCallIds: false`) has no coverage — a typo or copy-paste error in that block would go undetected. A second expectation like:

```ts
expect(
  portalProvider.buildReplayPolicy?.({
    provider: "minimax-portal",
    modelApi: "anthropic-messages",
    modelId: "MiniMax-M2.7",
  } as never),
).toMatchObject({
  sanitizeMode: "full",
  sanitizeToolCallIds: false,
  preserveSignatures: true,
  validateAnthropicTurns: true,
});
```

would close that gap.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "minimax: disable tool call ID sanitizati..." | Re-trigger Greptile

Comment on lines +247 to +256
buildReplayPolicy: (ctx) => {
const base = HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS.buildReplayPolicy?.(ctx);
if (!base) {
return base;
}
if (ctx.modelApi === "anthropic-messages") {
return { ...base, sanitizeToolCallIds: false };
}
return base;
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Duplicated buildReplayPolicy override block

The same 13-line block appears verbatim for both minimax and minimax-portal. The extensions/CLAUDE.md guide says: "If two bundled providers share the same replay policy shape … stop copying the logic. Extract one shared helper and migrate both call sites in the same change." Consider extracting this into a module-level helper, e.g.:

function buildMinimaxAnthropicReplayPolicy(ctx: ProviderReplayPolicyContext) {
  const base = HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS.buildReplayPolicy?.(ctx);
  if (!base) return base;
  if (ctx.modelApi === "anthropic-messages") {
    return { ...base, sanitizeToolCallIds: false };
  }
  return base;
}

and reference it in both provider registrations as buildReplayPolicy: buildMinimaxAnthropicReplayPolicy.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/minimax/provider-registration.ts
Line: 247-256

Comment:
**Duplicated `buildReplayPolicy` override block**

The same 13-line block appears verbatim for both `minimax` and `minimax-portal`. The `extensions/CLAUDE.md` guide says: "If two bundled providers share the same replay policy shape … stop copying the logic. Extract one shared helper and migrate both call sites in the same change." Consider extracting this into a module-level helper, e.g.:

```ts
function buildMinimaxAnthropicReplayPolicy(ctx: ProviderReplayPolicyContext) {
  const base = HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS.buildReplayPolicy?.(ctx);
  if (!base) return base;
  if (ctx.modelApi === "anthropic-messages") {
    return { ...base, sanitizeToolCallIds: false };
  }
  return base;
}
```

and reference it in both provider registrations as `buildReplayPolicy: buildMinimaxAnthropicReplayPolicy`.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a72a8572ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +152 to +154
if (!isWebSocketUrl(cdpUrl) && isLoopbackCdpUrl(cdpUrl)) {
return await isChromeReachableLoopback(cdpUrl, timeoutMs);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore SSRF gating for loopback CDP probes

This new early return skips assertCdpEndpointAllowed for loopback HTTP URLs, so a strict policy like dangerouslyAllowPrivateNetwork: false no longer blocks reachable 127.0.0.1/localhost CDP endpoints. The same bypass is mirrored in isChromeCdpReady through the loopback helper path, which makes policy enforcement inconsistent and allows connections that were previously denied under strict SSRF settings.

Useful? React with 👍 / 👎.

return new Promise<boolean>((resolve) => {
const versionUrl = appendCdpPath(cdpUrl, "/json/version");
const parsed = new URL(versionUrl);
const req = http.get(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle HTTPS loopback CDP URLs in raw readiness probes

The loopback probe always uses node:http regardless of the original URL scheme. For https://localhost/https://127.0.0.1 CDP endpoints (which are valid in this codebase), this sends plaintext HTTP to a TLS endpoint and causes false negatives for reachability/readiness, so secure loopback CDP setups regress after this change.

Useful? React with 👍 / 👎.

sebykrueger and others added 2 commits April 17, 2026 15:56
MiniMax generates its own tool call IDs and rejects tool results
if the echoed ID does not match exactly (error 2013). The default
strict sanitization rewrites IDs, breaking the roundtrip.

Override buildReplayPolicy for both minimax and minimax-portal
providers to set sanitizeToolCallIds: false when the API is
anthropic-messages. OpenAI-compatible paths keep sanitization.
@sebykrueger

Copy link
Copy Markdown
Author

Closing — superseded by #67967. The original patch was written against the pre-factory replay-hook API; the reworked version wraps HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS via a new MINIMAX_REPLAY_HOOKS object consumed by MINIMAX_PROVIDER_HOOKS, so both the minimax and minimax-portal providers inherit the override through the single spread. Same user-facing fix, updated plumbing.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MiniMax tool use broken: tool call ID sanitization causes error 2013 [Bug]: MiniMax models' tool calls are stripped instead of executed

1 participant