diff --git a/packages/coding-agent/test/model-discovery.test.ts b/packages/coding-agent/test/model-discovery.test.ts index c25d30010..d98f84d44 100644 --- a/packages/coding-agent/test/model-discovery.test.ts +++ b/packages/coding-agent/test/model-discovery.test.ts @@ -8,7 +8,7 @@ import type { OAuthCredentials } from "@oh-my-pi/pi-ai/oauth/types"; import { buildModel } from "@oh-my-pi/pi-catalog/build"; import { writeModelCache } from "@oh-my-pi/pi-catalog/model-cache"; import { getBundledModel } from "@oh-my-pi/pi-catalog/models"; -import { resolveOllamaModelCacheProviderId } from "@oh-my-pi/pi-catalog/provider-models"; +import { resolveModelCacheProviderId, resolveOllamaModelCacheProviderId } from "@oh-my-pi/pi-catalog/provider-models"; import type { ModelSpec, OpenAICompat } from "@oh-my-pi/pi-catalog/types"; import { applyLlamaCppQwenThinking, @@ -2562,9 +2562,10 @@ providers: }); // Emulate a legacy write: the variant has no same-id static header source, // so it is flagged unrestorable even though its base carries the headers. - writeModelCache("github-copilot", Date.now(), [cachedVariant], true, "", cacheDbPath); + const cacheProviderId = resolveModelCacheProviderId("github-copilot"); + writeModelCache(cacheProviderId, Date.now(), [cachedVariant], true, "", cacheDbPath); const db = new Database(cacheDbPath); - db.run("UPDATE model_cache SET header_restore_version = 0 WHERE provider_id = ?", ["github-copilot"]); + db.run("UPDATE model_cache SET header_restore_version = 0 WHERE provider_id = ?", [cacheProviderId]); db.close(); const registry = new ModelRegistry(authStorage, modelsJsonPath); @@ -2585,7 +2586,8 @@ providers: requestModelId: "gpt-5.6-sol", headers: { "X-Tenant-Route": "tenant-a" }, }); - writeModelCache("github-copilot", Date.now(), [cachedAlias], true, "", cacheDbPath, [bundledBase]); + const cacheProviderId = resolveModelCacheProviderId("github-copilot"); + writeModelCache(cacheProviderId, Date.now(), [cachedAlias], true, "", cacheDbPath, [bundledBase]); const registry = new ModelRegistry(authStorage, modelsJsonPath); diff --git a/packages/coding-agent/test/model-registry-cache-headers.test.ts b/packages/coding-agent/test/model-registry-cache-headers.test.ts index b8c830217..473fe0619 100644 --- a/packages/coding-agent/test/model-registry-cache-headers.test.ts +++ b/packages/coding-agent/test/model-registry-cache-headers.test.ts @@ -4,6 +4,7 @@ import * as os from "node:os"; import * as path from "node:path"; import { writeModelCache } from "@oh-my-pi/pi-catalog/model-cache"; import { getBundledModels } from "@oh-my-pi/pi-catalog/models"; +import { resolveModelCacheProviderId } from "@oh-my-pi/pi-catalog/provider-models"; import { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; import { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; import { removeSyncWithRetries } from "@oh-my-pi/pi-utils"; @@ -29,7 +30,8 @@ describe("startup model cache header restoration (#5780)", () => { expect(withHeaders.length).toBeGreaterThan(0); // Prior process: cache the live copilot catalog. v10 never persists headers. - writeModelCache("github-copilot", Date.now(), bundled, true, "fp-test", dbPath, bundled); + const cacheProviderId = resolveModelCacheProviderId("github-copilot"); + writeModelCache(cacheProviderId, Date.now(), bundled, true, "fp-test", dbPath, bundled); const raw = fs.readFileSync(dbPath).toString("latin1"); for (const model of withHeaders) { for (const value of Object.values(model.headers ?? {})) {