TypeScript
fix(server): searching delegate models no longer drops words found inside the provider name (#26502)
MINIT49f6cbacc4ef
diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.tsindex 6450f9acac2..9f27dc69363 100644--- a/apps/server/src/mcp/OrchestratorMcpService.test.ts+++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts@@ -1303,6 +1303,7 @@ describe("OrchestratorMcpService provider resolution", () => {instanceId: codexInstanceId,driver: ProviderDriverKind.make("codex"),}),+ displayName: "Codex",models: [model("gpt-6", {name: "Sol",@@ -1330,7 +1331,7 @@ describe("OrchestratorMcpService provider resolution", () => {],},}),- model("gpt-5", { isLegacy: true }),+ model("gpt-5", { name: "Code Legacy", isLegacy: true }),model("gpt-4", { isLegacy: true }),model("gpt-3", { name: "GPT-3", isLegacy: true }),model("my-alpha", { isCustom: true }),@@ -1436,6 +1437,18 @@ describe("OrchestratorMcpService provider resolution", () => {{ id: codexInstanceId, models: ["gpt-6", "gpt-4", "gpt-3", "my-alpha"], omitted: 1 },{ id: opencodeInstanceId, models: [], omitted: 0 },]);+ assert.deepEqual(listing(yield* capabilitiesWith(" ")), listing(yield* capabilitiesWith()));+ for (const search of ["code", "codex code", " CODE "]) {+ assert.deepEqual(listing(yield* capabilitiesWith(search))[0], {+ id: codexInstanceId,+ models: ["gpt-5"],+ omitted: 0,+ });+ }+ assert.deepEqual(+ listing(yield* capabilitiesWith("open"))[1],+ listing(yield* capabilitiesWith())[1],+ );assert.deepEqual(listing(yield* capabilitiesWith("codex gpt 5"))[0], {id: codexInstanceId,models: ["gpt-5"],diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.tsindex 0eb2d0e8ea8..5037df3b683 100644--- a/apps/server/src/mcp/OrchestratorMcpService.ts+++ b/apps/server/src/mcp/OrchestratorMcpService.ts@@ -287,10 +287,8 @@ 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. 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.+ * Lists visible models, keeping pinned models and limiting large catalogs by default.+ * Whole provider words select the provider; partial words filter models when any match.*/function listCapabilityModels(input: {readonly provider: ServerProvider;@@ -306,10 +304,22 @@ function listCapabilityModels(input: {.toSorted((a, b) => (rank.get(a.slug) ?? rank.size) - (rank.get(b.slug) ?? rank.size));const { instanceId, driver, displayName } = input.provider;const providerText = `${instanceId} ${driver} ${displayName ?? ""}`.toLowerCase();- const modelTerms = input.searchTerms.filter((term) => !providerText.includes(term));+ // Whole ids like "codex-work" and their parts both name the provider.+ const providerWords = new Set([+ ...providerText.split(/\s+/),+ ...providerText.split(/[^\p{L}\p{N}]+/u),+ ]);+ const modelText = (model: ServerProviderModel) =>+ `${model.slug} ${model.name} ${model.subProvider ?? ""}`.toLowerCase();+ // Part of a provider word ("agent" in "claudeAgent") names the provider unless a model matches it.+ const modelTerms = input.searchTerms.filter(+ (term) =>+ !providerWords.has(term) &&+ (!providerText.includes(term) || visible.some((model) => modelText(model).includes(term))),+ );if (modelTerms.length > 0) {const matches = visible.filter((model) => {- const text = `${model.slug} ${model.name} ${model.subProvider ?? ""}`.toLowerCase();+ const text = modelText(model);return modelTerms.every((term) => text.includes(term));});const listed = matches.slice(0, LISTED_MODEL_LIMIT);@@ -2138,7 +2148,7 @@ const make = Effect.gen(function* () {Effect.mapError(() => failure("orchestration_error", "Unable to read server settings.")),);const inherited = parent?.thread.modelSelection;- const searchTerms = input.search?.toLowerCase().split(/\s+/) ?? [];+ const searchTerms = input.search?.toLowerCase().split(/\s+/).filter(Boolean) ?? [];return {parentThreadId: parent?.thread.id ?? null,inheritedProviderInstanceId: inherited?.instanceId ?? null,