Merge pull request #3560 from Tibsfox/fix/ollama-stream-simple-crash

fix(ollama): use apiKey auth mode to avoid streamSimple crash
This commit is contained in:
Jeremy McSpadden 2026-04-05 15:22:38 -05:00 committed by GitHub
commit 369303f82f
2 changed files with 26 additions and 1 deletions

View file

@ -61,8 +61,13 @@ async function probeAndRegister(pi: ExtensionAPI): Promise<boolean> {
const baseUrl = client.getOllamaHost();
// Use authMode "apiKey" with a dummy key (#3440).
// authMode "none" requires a custom streamSimple handler, but Ollama uses
// the standard OpenAI-compatible streaming endpoint. Ollama ignores the
// Authorization header so the dummy key is harmless.
pi.registerProvider("ollama", {
authMode: "none",
authMode: "apiKey",
apiKey: "ollama",
baseUrl,
api: "ollama-chat",
streamSimple: streamOllamaChat,

View file

@ -0,0 +1,20 @@
/**
* Regression test for #3440: Ollama extension must register with
* authMode "apiKey" (not "none") to avoid streamSimple requirement.
*/
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
test("Ollama registers with authMode apiKey, not none (#3440)", () => {
const src = readFileSync(join(__dirname, "index.ts"), "utf-8");
// Find the registerProvider call
const registerBlock = src.slice(src.indexOf("pi.registerProvider(\"ollama\""));
const authLine = registerBlock.match(/authMode:\s*"(\w+)"/);
assert.ok(authLine, "registerProvider must specify authMode");
assert.equal(authLine![1], "apiKey", "authMode must be apiKey, not none");
});