Skip to content

Commit 8bdd08e

Browse files
sebykruegerUbuntu
authored andcommitted
minimax: disable tool call ID sanitization for Anthropic-compatible API
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.
1 parent 42805d2 commit 8bdd08e

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎extensions/minimax/index.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe("minimax provider hooks", () => {
136136
} as never),
137137
).toMatchObject({
138138
sanitizeMode: "full",
139-
sanitizeToolCallIds: true,
139+
sanitizeToolCallIds: false,
140140
preserveSignatures: true,
141141
validateAnthropicTurns: true,
142142
});

‎extensions/minimax/provider-registration.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,25 @@ const HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS = buildProviderReplayFamilyHooks({
4242
family: "hybrid-anthropic-openai",
4343
anthropicModelDropThinkingBlocks: true,
4444
});
45-
const MINIMAX_PROVIDER_HOOKS = {
45+
// MiniMax's Anthropic-compatible API generates its own tool call IDs and
46+
// rejects tool results if the echoed ID doesn't match exactly (error 2013).
47+
// Disable tool call ID sanitization so IDs roundtrip verbatim for that API;
48+
// OpenAI-compatible paths keep default sanitization.
49+
const MINIMAX_REPLAY_HOOKS: typeof HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS = {
4650
...HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS,
51+
buildReplayPolicy: (ctx) => {
52+
const base = HYBRID_ANTHROPIC_OPENAI_REPLAY_HOOKS.buildReplayPolicy?.(ctx);
53+
if (!base) {
54+
return base;
55+
}
56+
if (ctx.modelApi === "anthropic-messages") {
57+
return { ...base, sanitizeToolCallIds: false };
58+
}
59+
return base;
60+
},
61+
};
62+
const MINIMAX_PROVIDER_HOOKS = {
63+
...MINIMAX_REPLAY_HOOKS,
4764
...MINIMAX_FAST_MODE_STREAM_HOOKS,
4865
resolveReasoningOutputMode: () => "native" as const,
4966
};

0 commit comments

Comments
 (0)