From beeabe2e4b9e7a9a5e0a645c92ce479c3cc1847f Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:20:07 -0500 Subject: [PATCH] fix(mistral): pass through reasoning effort (#42164) Co-authored-by: Aiden Cline --- packages/core/test/provider-mistral.test.ts | 26 ++++++++++++++++++++ patches/@ai-sdk%2Fmistral@3.0.51.patch | 27 ++++++++++++--------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/packages/core/test/provider-mistral.test.ts b/packages/core/test/provider-mistral.test.ts index 6e3176695f6..5841bcb6cdc 100644 --- a/packages/core/test/provider-mistral.test.ts +++ b/packages/core/test/provider-mistral.test.ts @@ -27,6 +27,32 @@ test("Mistral sends promptCacheKey as prompt_cache_key", async () => { expect(body?.prompt_cache_key).toBe("session-123") }) +test("Mistral passes through unknown reasoning effort", async () => { + let body: Record | undefined + const mockFetch = Object.assign( + async (_input: Parameters[0], init?: RequestInit) => { + body = JSON.parse(String(init?.body)) + return Response.json({ + id: "response-1", + created: 0, + model: "mistral-large-latest", + object: "chat.completion", + choices: [{ index: 0, message: { role: "assistant", content: "Hello" }, finish_reason: "stop" }], + usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }, + }) + }, + { preconnect: fetch.preconnect }, + ) + const model = createMistral({ apiKey: "test", fetch: mockFetch })("mistral-large-latest") + + await model.doGenerate({ + prompt: [{ role: "user", content: [{ type: "text", text: "Hello" }] }], + providerOptions: { mistral: { reasoningEffort: "custom" } }, + }) + + expect(body?.reasoning_effort).toBe("custom") +}) + test("Mistral round-trips native reasoning in assistant history", async () => { let body: { messages?: unknown[] } | undefined const mockFetch = Object.assign( diff --git a/patches/@ai-sdk%2Fmistral@3.0.51.patch b/patches/@ai-sdk%2Fmistral@3.0.51.patch index 141b14a689b..f76ed1c126e 100644 --- a/patches/@ai-sdk%2Fmistral@3.0.51.patch +++ b/patches/@ai-sdk%2Fmistral@3.0.51.patch @@ -2,10 +2,12 @@ diff --git a/dist/index.d.mts b/dist/index.d.mts index 1bde0b9f8cbe6771a52c1041095c9dddfe8e5b6c..0ca2ffb2a0c9327aed5ddcf0004500dc8b42569f 100644 --- a/dist/index.d.mts +++ b/dist/index.d.mts -@@ -14,6 +14,7 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ - none: "none"; - high: "high"; - }>>; +@@ -13,7 +13,5 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ +- reasoningEffort: z.ZodOptional>; ++ reasoningEffort: z.ZodOptional; + promptCacheKey: z.ZodOptional; }, z.core.$strip>; type MistralLanguageModelOptions = z.infer; @@ -14,10 +16,12 @@ diff --git a/dist/index.d.ts b/dist/index.d.ts index 1bde0b9f8cbe6771a52c1041095c9dddfe8e5b6c..0ca2ffb2a0c9327aed5ddcf0004500dc8b42569f 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts -@@ -14,6 +14,7 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ - none: "none"; - high: "high"; - }>>; +@@ -13,7 +13,5 @@ declare const mistralLanguageModelOptions: z.ZodObject<{ +- reasoningEffort: z.ZodOptional>; ++ reasoningEffort: z.ZodOptional; + promptCacheKey: z.ZodOptional; }, z.core.$strip>; type MistralLanguageModelOptions = z.infer; @@ -69,7 +73,7 @@ index d3f904c12a1d582cc7b9e9a2d30273e1a8505b28..267f34e20ea392b7a85ad5259d72d506 * - `'none'`: Disable reasoning */ - reasoningEffort: import_v4.z.enum(["high", "none"]).optional() -+ reasoningEffort: import_v4.z.enum(["high", "none"]).optional(), ++ reasoningEffort: import_v4.z.string().optional(), + promptCacheKey: import_v4.z.string().optional() }); @@ -268,7 +272,7 @@ index d2eff622c1b84a96bdeb4012cb0206a33012a04d..3bff11ddd6136ada45809568828cbc8f * - `'none'`: Disable reasoning */ - reasoningEffort: z.enum(["high", "none"]).optional() -+ reasoningEffort: z.enum(["high", "none"]).optional(), ++ reasoningEffort: z.string().optional(), + promptCacheKey: z.string().optional() }); @@ -655,7 +659,8 @@ index 54b29c08517d348995b6ca093b11160e453d5c8b..de30c3e7d924889339e38b1067cb26e9 @@ -64,6 +64,11 @@ export const mistralLanguageModelOptions = z.object({ * - `'none'`: Disable reasoning */ - reasoningEffort: z.enum(['high', 'none']).optional(), +- reasoningEffort: z.enum(['high', 'none']).optional(), ++ reasoningEffort: z.string().optional(), + + /** + * A stable identifier used to route requests with shared prompt prefixes.