From 19f9b69586d3279bd648e35d76346150a4aca497 Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 24 Apr 2026 01:09:37 +0100 Subject: [PATCH] fix: include configured provider rows in all models list --- src/commands/models.list.e2e.test.ts | 5 ++++- src/commands/models/list.list-command.ts | 12 +++++------- src/commands/models/list.rows.ts | 13 +++++++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/commands/models.list.e2e.test.ts b/src/commands/models.list.e2e.test.ts index d7abb2c4889..f4562c60088 100644 --- a/src/commands/models.list.e2e.test.ts +++ b/src/commands/models.list.e2e.test.ts @@ -474,7 +474,9 @@ describe("models list/status", () => { models: { providers: { "custom-proxy": { + api: "openai-responses", baseUrl: "https://custom.example/v1", + apiKey: "$CUSTOM_PROXY_API_KEY", models: [ { id: "custom-model", @@ -491,6 +493,7 @@ describe("models list/status", () => { models: { providers: { "custom-proxy": { + api: "openai-responses", baseUrl: "https://custom.example/v1", apiKey: "sk-resolved-runtime-value", // pragma: allowlist secret models: [ @@ -512,7 +515,7 @@ describe("models list/status", () => { getRuntimeConfig.mockReturnValue(resolvedConfig); const runtime = makeRuntime(); - await modelsListCommand({ all: true, provider: "custom-proxy", json: true }, runtime); + await modelsListCommand({ all: true, json: true }, runtime); expect(ensureOpenClawModelsJson).not.toHaveBeenCalled(); const payload = parseJsonLog(runtime); diff --git a/src/commands/models/list.list-command.ts b/src/commands/models/list.list-command.ts index 3ffee8e69c7..3345fc51836 100644 --- a/src/commands/models/list.list-command.ts +++ b/src/commands/models/list.list-command.ts @@ -104,13 +104,11 @@ export async function modelsListCommand( context: rowContext, }); - if (providerFilter) { - appendConfiguredProviderRows({ - rows, - context: rowContext, - seenKeys, - }); - } + appendConfiguredProviderRows({ + rows, + context: rowContext, + seenKeys, + }); if (modelRegistry) { await appendCatalogSupplementRows({ diff --git a/src/commands/models/list.rows.ts b/src/commands/models/list.rows.ts index 88e0aa3fd1c..1cd8d64b125 100644 --- a/src/commands/models/list.rows.ts +++ b/src/commands/models/list.rows.ts @@ -104,6 +104,16 @@ function toConfiguredProviderListModel(params: { }; } +function shouldListConfiguredProviderModel(params: { + providerConfig: Partial; + model: Partial; +}): boolean { + return ( + params.providerConfig.apiKey !== undefined && + (params.providerConfig.api !== undefined || params.model.api !== undefined) + ); +} + export async function loadListModelRegistry( cfg: OpenClawConfig, opts?: { providerFilter?: string }, @@ -159,6 +169,9 @@ export function appendConfiguredProviderRows(params: { params.context.cfg.models?.providers ?? {}, )) { for (const configuredModel of providerConfig.models ?? []) { + if (!shouldListConfiguredProviderModel({ providerConfig, model: configuredModel })) { + continue; + } const key = modelKey(provider, configuredModel.id); if (params.seenKeys.has(key)) { continue;