fix(provider): remove conflicting MiniMax controls

This commit is contained in:
Aiden Cline 2026-07-21 21:10:27 -05:00
commit 6007304aaa
2 changed files with 26 additions and 25 deletions

View file

@ -684,12 +684,6 @@ function googleThinkingVariants(model: Provider.Model): Record<string, Record<st
function minimaxM3ThinkingVariants(model: Provider.Model): Provider.Model["variants"] { function minimaxM3ThinkingVariants(model: Provider.Model): Provider.Model["variants"] {
if (!model.api.id.toLowerCase().includes("minimax-m3")) return if (!model.api.id.toLowerCase().includes("minimax-m3")) return
if (model.providerID === "kilo" && model.api.npm === "@ai-sdk/openai-compatible") {
return {
none: { reasoning: { enabled: false } },
thinking: { reasoning: { enabled: true } },
}
}
if (!["@ai-sdk/anthropic", "@ai-sdk/openai-compatible"].includes(model.api.npm)) return if (!["@ai-sdk/anthropic", "@ai-sdk/openai-compatible"].includes(model.api.npm)) return
if (["nvidia", "lilac"].includes(model.providerID)) { if (["nvidia", "lilac"].includes(model.providerID)) {
return { return {
@ -1319,15 +1313,21 @@ const SLUG_OVERRIDES: Record<string, string> = {
} }
export function providerOptions(model: Provider.Model, options: { [x: string]: any }) { export function providerOptions(model: Provider.Model, options: { [x: string]: any }) {
const cleaned =
model.api.id.toLowerCase().includes("minimax-m3") &&
["nvidia", "lilac"].includes(model.providerID) &&
options.chat_template_kwargs?.thinking_mode !== undefined
? Object.fromEntries(Object.entries(options).filter(([key]) => key !== "thinking"))
: options
const usesOpenAIReasoningGate = const usesOpenAIReasoningGate =
model.api.npm === "@ai-sdk/openai" || model.api.npm === "@ai-sdk/openai" ||
model.api.npm === "@ai-sdk/azure" || model.api.npm === "@ai-sdk/azure" ||
model.api.npm === "@ai-sdk/amazon-bedrock/mantle" model.api.npm === "@ai-sdk/amazon-bedrock/mantle"
const normalized = const normalized =
usesOpenAIReasoningGate && usesOpenAIReasoningGate &&
(model.capabilities.reasoning || options.reasoningEffort !== undefined || options.reasoningSummary !== undefined) (model.capabilities.reasoning || cleaned.reasoningEffort !== undefined || cleaned.reasoningSummary !== undefined)
? { ...options, forceReasoning: true } ? { ...cleaned, forceReasoning: true }
: options : cleaned
if (model.api.npm === "@ai-sdk/gateway") { if (model.api.npm === "@ai-sdk/gateway") {
// Gateway providerOptions are split across two namespaces: // Gateway providerOptions are split across two namespaces:

View file

@ -3309,14 +3309,6 @@ describe("ProviderTransform.reasoningVariants", () => {
thinking: { chat_template_kwargs: { thinking_mode: "enabled" } }, thinking: { chat_template_kwargs: { thinking_mode: "enabled" } },
}, },
], ],
[
"kilo",
"@ai-sdk/openai-compatible",
{
none: { reasoning: { enabled: false } },
thinking: { reasoning: { enabled: true } },
},
],
])("maps MiniMax M3 toggle options for %s", (providerID, npm, expected) => { ])("maps MiniMax M3 toggle options for %s", (providerID, npm, expected) => {
expect( expect(
ProviderTransform.reasoningVariants(model([{ type: "toggle" }]), target(npm, "minimaxai/minimax-m3", providerID)), ProviderTransform.reasoningVariants(model([{ type: "toggle" }]), target(npm, "minimaxai/minimax-m3", providerID)),
@ -3538,13 +3530,16 @@ describe("ProviderTransform.variants", () => {
}) })
}) })
test("nvidia minimax m3 sends chat template thinking toggles", async () => { test.each([
["nvidia", "https://integrate.api.nvidia.com/v1"],
["lilac", "https://api.getlilac.com/v1"],
])("%s minimax m3 sends chat template thinking toggles", async (providerID, baseURL) => {
const model = createMockModel({ const model = createMockModel({
id: "nvidia/minimaxai/minimax-m3", id: `${providerID}/minimaxai/minimax-m3`,
providerID: "nvidia", providerID,
api: { api: {
id: "minimaxai/minimax-m3", id: "minimaxai/minimax-m3",
url: "https://integrate.api.nvidia.com/v1", url: baseURL,
npm: "@ai-sdk/openai-compatible", npm: "@ai-sdk/openai-compatible",
}, },
}) })
@ -3553,6 +3548,9 @@ describe("ProviderTransform.variants", () => {
none: { chat_template_kwargs: { thinking_mode: "disabled" } }, none: { chat_template_kwargs: { thinking_mode: "disabled" } },
thinking: { chat_template_kwargs: { thinking_mode: "enabled" } }, thinking: { chat_template_kwargs: { thinking_mode: "enabled" } },
}) })
expect(ProviderTransform.providerOptions(model, { thinking: { type: "adaptive" } })).toEqual({
[providerID]: { thinking: { type: "adaptive" } },
})
let body: Record<string, unknown> | undefined let body: Record<string, unknown> | undefined
const captureFetch: typeof fetch = Object.assign( const captureFetch: typeof fetch = Object.assign(
@ -3573,18 +3571,21 @@ describe("ProviderTransform.variants", () => {
{ preconnect: fetch.preconnect.bind(fetch) }, { preconnect: fetch.preconnect.bind(fetch) },
) )
const provider = createOpenAICompatible({ const provider = createOpenAICompatible({
name: "nvidia", name: providerID,
baseURL: "https://integrate.api.nvidia.com/v1", baseURL,
apiKey: "test", apiKey: "test",
fetch: captureFetch, fetch: captureFetch,
}) })
await generateText({ await generateText({
model: provider(model.api.id), model: provider(model.api.id),
prompt: "test", prompt: "test",
providerOptions: ProviderTransform.providerOptions(model, variants.thinking), providerOptions: ProviderTransform.providerOptions(model, {
thinking: { type: "adaptive" },
...variants.none,
}),
}) })
expect(body?.chat_template_kwargs).toEqual({ thinking_mode: "enabled" }) expect(body?.chat_template_kwargs).toEqual({ thinking_mode: "disabled" })
expect(body?.thinking).toBeUndefined() expect(body?.thinking).toBeUndefined()
}) })