From d6396ac86f5d5f0eecd8dbda89c6bcd7314e6b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=89=BA=E9=9F=AC=28yangyitao=29?= Date: Sat, 21 Mar 2026 02:55:17 +0000 Subject: [PATCH] =?UTF-8?q?fix(ollama):=20revert=20"off"=20guard=20?= =?UTF-8?q?=E2=80=94=20ThinkingLevel=20excludes=20"off"=20at=20type=20leve?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pi-ai ThinkingLevel = "minimal"|"low"|"medium"|"high"|"xhigh" (no "off"). The !== "off" check caused TS2367. Remove guard and test since the type system already prevents reasoning="off" from reaching this code path. --- src/agents/ollama-stream.test.ts | 27 --------------------------- src/agents/ollama-stream.ts | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/agents/ollama-stream.test.ts b/src/agents/ollama-stream.test.ts index 03d35834db7..3e465ec8368 100644 --- a/src/agents/ollama-stream.test.ts +++ b/src/agents/ollama-stream.test.ts @@ -598,33 +598,6 @@ describe("createOllamaStreamFn", () => { }, ); }); - - it("sends think:false when reasoning is 'off'", 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 streamFn = createOllamaStreamFn("http://ollama-host:11434"); - const stream = await streamFn( - { - id: "deepseek-r1:32b", - api: "ollama", - provider: "ollama", - contextWindow: 131072, - } as never, - { messages: [{ role: "user", content: "hello" }] } as never, - { reasoning: "off" } as never, - ); - await collectStreamEvents(stream); - - const [, reqInit] = fetchMock.mock.calls[0] as unknown as [string, RequestInit]; - const body = JSON.parse(reqInit.body as string) as { think?: boolean }; - expect(body.think).toBe(false); - }, - ); - }); }); describe("resolveOllamaBaseUrlForRun", () => { diff --git a/src/agents/ollama-stream.ts b/src/agents/ollama-stream.ts index 1c3048b67a1..6a8fd608914 100644 --- a/src/agents/ollama-stream.ts +++ b/src/agents/ollama-stream.ts @@ -464,7 +464,7 @@ export function createOllamaStreamFn( // `think` boolean. Forward the reasoning level so `think: false` is // sent explicitly when thinking is disabled (#46680). const thinkParam: { think?: boolean } = {}; - if (options?.reasoning && options.reasoning !== "off") { + if (options?.reasoning) { thinkParam.think = true; } else if (options) { // Thinking explicitly disabled – tell Ollama not to think.