From e3ad694d7a23a627ef8c77050653224c9456a949 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Sun, 5 Apr 2026 22:08:52 -0700 Subject: [PATCH] fix(engine): load custom models.json in createKbAgent Pass the user's models.json path to ModelRegistry so custom and non-built-in models (e.g. openrouter/qwen/qwen3.6-plus:free) are available when resolving the configured primary/fallback model. The pi CLI was already passing this path; kb was not, causing 'model not found in registry' errors for any model not built-in. Co-Authored-By: Claude Sonnet 4.6 --- packages/engine/src/pi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/engine/src/pi.ts b/packages/engine/src/pi.ts index 7deca1650..8273c4869 100644 --- a/packages/engine/src/pi.ts +++ b/packages/engine/src/pi.ts @@ -249,7 +249,7 @@ async function registerExtensionProviders(cwd: string, modelRegistry: ModelRegis export async function createKbAgent(options: AgentOptions): Promise { console.log(`[pi] createKbAgent called (cwd=${options.cwd}, tools=${options.tools}, provider=${options.defaultProvider}, model=${options.defaultModelId})`); const authStorage = AuthStorage.create(); - const modelRegistry = new ModelRegistry(authStorage); + const modelRegistry = new ModelRegistry(authStorage, join(getAgentDir(), "models.json")); await registerExtensionProviders(options.cwd, modelRegistry); const tools =