From 3698df1bc34a93394032e00e007e7ed99cd81fe0 Mon Sep 17 00:00:00 2001 From: Rakshith N Date: Mon, 13 Jul 2026 17:31:19 +0530 Subject: [PATCH] fix(cli): skip Kilo model catalog resolution when indexing is disabled Return early from model() when indexing is disabled so a disabled Kilo config no longer resolves the embedding model catalog (and its baseUrl) or surfaces a model-validation error. Adds a regression test asserting a disabled config with an invalid kilo.baseUrl reaches Disabled without calling fetch. --- packages/opencode/src/kilocode/indexing.ts | 4 +-- .../test/kilocode/indexing-startup.test.ts | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/kilocode/indexing.ts b/packages/opencode/src/kilocode/indexing.ts index 3d145a2e8ed..11b7d59171f 100644 --- a/packages/opencode/src/kilocode/indexing.ts +++ b/packages/opencode/src/kilocode/indexing.ts @@ -94,14 +94,14 @@ function enrichKilo(input: ReturnType, auth: KiloI } async function model(input: ReturnType, auth: KiloIndexingAuth) { - if (input.embedderProvider !== "kilo") return input + if (input.embedderProvider !== "kilo" || !input.enabled) return input const catalog = await fetchKiloEmbeddingModelCatalog({ baseURL: auth.baseUrl, token: auth.apiKey }) if (input.modelId) { const id = catalog.aliases[input.modelId] ?? input.modelId const chosen = catalog.models.find((item) => item.id === id) - if (catalog.models.length > 0 && !chosen && input.enabled !== false) { + if (catalog.models.length > 0 && !chosen) { throw new IndexingModelError({ model: input.modelId }) } if (chosen) { diff --git a/packages/opencode/test/kilocode/indexing-startup.test.ts b/packages/opencode/test/kilocode/indexing-startup.test.ts index 0e457848348..80fa555bbae 100644 --- a/packages/opencode/test/kilocode/indexing-startup.test.ts +++ b/packages/opencode/test/kilocode/indexing-startup.test.ts @@ -568,6 +568,40 @@ describe("indexing startup degradation", () => { } }) + test("disabled indexing does not resolve the Kilo model catalog", async () => { + const fetchSpy = spyOn(globalThis, "fetch") + const key = process.env.KILO_API_KEY + + const config: Partial = { + ...staleKilo, + indexing: { + ...staleKilo.indexing, + enabled: false, + model: "removed/model", + kilo: { baseUrl: "not a url" }, + }, + } + await using tmp = await tmpdir({ git: true, config }) + process.env["KILO_CONFIG_DIR"] = tmp.path + process.env.KILO_API_KEY = "kilo-token" + + try { + await provideTestInstance({ + directory: tmp.path, + init: Effect.promise(() => KiloIndexing.init()), + fn: async () => { + const status = await wait(() => KiloIndexing.current(), "Disabled") + expect(status.state).toBe("Disabled") + expect(fetchSpy).not.toHaveBeenCalled() + }, + }) + } finally { + if (key === undefined) delete process.env.KILO_API_KEY + else process.env.KILO_API_KEY = key + fetchSpy.mockRestore() + } + }) + test("does not allocate an engine when indexing configuration is disabled", async () => { const created: string[] = [] IndexingWorker.override((directory, root, hooks) => {