Skip to content

Commit 519178d

Browse files
committed
fix(server): searching delegate models no longer drops words found inside the provider name
1 parent 5211acf commit 519178d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎apps/server/src/mcp/OrchestratorMcpService.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ describe("OrchestratorMcpService provider resolution", () => {
13301330
],
13311331
},
13321332
}),
1333-
model("gpt-5", { isLegacy: true }),
1333+
model("gpt-5", { name: "Code Legacy", isLegacy: true }),
13341334
model("gpt-4", { isLegacy: true }),
13351335
model("gpt-3", { name: "GPT-3", isLegacy: true }),
13361336
model("my-alpha", { isCustom: true }),
@@ -1436,6 +1436,12 @@ describe("OrchestratorMcpService provider resolution", () => {
14361436
{ id: codexInstanceId, models: ["gpt-6", "gpt-4", "gpt-3", "my-alpha"], omitted: 1 },
14371437
{ id: opencodeInstanceId, models: [], omitted: 0 },
14381438
]);
1439+
// A word that only appears inside the provider's name is a model word, not the provider.
1440+
assert.deepEqual(listing(yield* capabilitiesWith("code"))[0], {
1441+
id: codexInstanceId,
1442+
models: ["gpt-5"],
1443+
omitted: 0,
1444+
});
14391445
assert.deepEqual(listing(yield* capabilitiesWith("codex gpt 5"))[0], {
14401446
id: codexInstanceId,
14411447
models: ["gpt-5"],

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,12 @@ function listCapabilityModels(input: {
306306
.toSorted((a, b) => (rank.get(a.slug) ?? rank.size) - (rank.get(b.slug) ?? rank.size));
307307
const { instanceId, driver, displayName } = input.provider;
308308
const providerText = `${instanceId} ${driver} ${displayName ?? ""}`.toLowerCase();
309-
const modelTerms = input.searchTerms.filter((term) => !providerText.includes(term));
309+
// Whole ids like "codex-work" and their parts both name the provider.
310+
const providerWords = new Set([
311+
...providerText.split(/\s+/),
312+
...providerText.split(/[^\p{L}\p{N}]+/u),
313+
]);
314+
const modelTerms = input.searchTerms.filter((term) => !providerWords.has(term));
310315
if (modelTerms.length > 0) {
311316
const matches = visible.filter((model) => {
312317
const text = `${model.slug} ${model.name} ${model.subProvider ?? ""}`.toLowerCase();

0 commit comments

Comments
 (0)