diff --git a/extensions/ollama/src/stream-runtime.test.ts b/extensions/ollama/src/stream-runtime.test.ts index a34862aaf4c..4fc712f26bd 100644 --- a/extensions/ollama/src/stream-runtime.test.ts +++ b/extensions/ollama/src/stream-runtime.test.ts @@ -1246,6 +1246,35 @@ describe("createOllamaStreamFn", () => { ); }); + it("maps configured native Ollama params.thinking=max to the stable top-level think value", async () => { + await withMockNdjsonFetch( + [ + '{"model":"m","created_at":"t","message":{"role":"assistant","content":"ok"},"done":false}', + '{"model":"m","created_at":"t","message":{"role":"assistant","content":""},"done":true,"prompt_eval_count":1,"eval_count":1}', + ], + async (fetchMock) => { + const stream = await createOllamaTestStream({ + baseUrl: "http://ollama-host:11434", + model: { params: { thinking: "max" } }, + }); + + const events = await collectStreamEvents(stream); + expect(events.at(-1)?.type).toBe("done"); + + const requestInit = getGuardedFetchCall(fetchMock).init ?? {}; + if (typeof requestInit.body !== "string") { + throw new Error("Expected string request body"); + } + const requestBody = JSON.parse(requestInit.body) as { + think?: string; + options?: { think?: string }; + }; + expect(requestBody.think).toBe("high"); + expect(requestBody.options?.think).toBeUndefined(); + }, + ); + }); + it("uses the default loopback policy when baseUrl is empty", async () => { await withMockNdjsonFetch( [ diff --git a/extensions/ollama/src/stream.ts b/extensions/ollama/src/stream.ts index 29fd46523d1..aeac03084c5 100644 --- a/extensions/ollama/src/stream.ts +++ b/extensions/ollama/src/stream.ts @@ -152,7 +152,7 @@ export function wrapOllamaCompatNumCtx(baseFn: StreamFn | undefined, numCtx: num }); } -type OllamaThinkValue = boolean | "low" | "medium" | "high" | "max"; +type OllamaThinkValue = boolean | "low" | "medium" | "high"; const OLLAMA_OPTION_PARAM_KEYS = new Set([ "num_keep", @@ -215,9 +215,15 @@ function resolveOllamaThinkParamValue( if (raw === "off") { return false; } - if (raw === "low" || raw === "medium" || raw === "high" || raw === "max") { + if (raw === "low" || raw === "medium" || raw === "high") { return raw; } + if (raw === "minimal") { + return "low"; + } + if (raw === "xhigh" || raw === "adaptive" || raw === "max") { + return "high"; + } return undefined; }