TypeScript
fix(server): searching delegate models by provider name no longer shows only dead models (#26448)
Theo Brownec280e640c119
diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.tsindex 4996044d7cd..6450f9acac2 100644--- a/apps/server/src/mcp/OrchestratorMcpService.test.ts+++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts@@ -1431,6 +1431,16 @@ describe("OrchestratorMcpService provider resolution", () => {models: ["oc/m12", "oc/m01", "oc/m03", "oc/m04", "oc/m05", "oc/m06", "oc/m07", "oc/m08"],omitted: 3,});+ // A word naming the provider matches all its models, so legacy ones stay out.+ assert.deepEqual(listing(yield* capabilitiesWith("Codex")), [+ { id: codexInstanceId, models: ["gpt-6", "gpt-4", "gpt-3", "my-alpha"], omitted: 1 },+ { id: opencodeInstanceId, models: [], omitted: 0 },+ ]);+ assert.deepEqual(listing(yield* capabilitiesWith("codex gpt 5"))[0], {+ id: codexInstanceId,+ models: ["gpt-5"],+ omitted: 0,+ });}),);diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.tsindex 6e5b8d06db2..8b32603a719 100644--- a/apps/server/src/mcp/OrchestratorMcpService.ts+++ b/apps/server/src/mcp/OrchestratorMcpService.ts@@ -287,9 +287,9 @@ const FULL_CATALOG_DRIVERS: ReadonlySet<string> = new Set(["codex", "claudeAgentconst LISTED_MODEL_LIMIT = 8;/**- * Picks the models orchestrator_capabilities shows for one provider. Hidden- * models never appear. With search terms, lists matches; otherwise lists pinned- * models (custom, favorite, the caller's own) plus the provider's non-legacy+ * Picks the models orchestrator_capabilities shows for one provider. Hidden models never+ * appear. Search words naming the provider are dropped; other words list matches. With no+ * words left, lists pinned models (custom, favorite, the caller's own) plus non-legacy* models, or only the first few in the user's model order for large catalogs.*/function listCapabilityModels(input: {@@ -304,10 +304,13 @@ function listCapabilityModels(input: {const visible = input.provider.models.filter((model) => model.isCustom || !input.preferences?.hiddenModels.includes(model.slug)).toSorted((a, b) => (rank.get(a.slug) ?? rank.size) - (rank.get(b.slug) ?? rank.size));- if (input.searchTerms.length > 0) {+ const { instanceId, driver, displayName } = input.provider;+ const providerText = `${instanceId} ${driver} ${displayName ?? ""}`.toLowerCase();+ const modelTerms = input.searchTerms.filter((term) => !providerText.includes(term));+ if (modelTerms.length > 0) {const matches = visible.filter((model) => {const text = `${model.slug} ${model.name} ${model.subProvider ?? ""}`.toLowerCase();- return input.searchTerms.every((term) => text.includes(term));+ return modelTerms.every((term) => text.includes(term));});const listed = matches.slice(0, LISTED_MODEL_LIMIT);return { listed, omitted: matches.length - listed.length };