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 <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-05 22:08:52 -07:00
parent 258cc34a7d
commit f2c95fe517

View File

@@ -249,7 +249,7 @@ async function registerExtensionProviders(cwd: string, modelRegistry: ModelRegis
export async function createKbAgent(options: AgentOptions): Promise<AgentResult> {
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 =