From af86d121e5d305b9a59b0393352f1a7e6d5b0eba Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 6 Nov 2026 08:53:32 +0000 Subject: [PATCH 1/3] test(server): reproduce #31890 unadvertised model refusal names no retry slug delegate_task refuses a model the provider does not advertise with only "Model is not advertised by provider .", so the agent must call orchestrator_capabilities again before retrying. This test asks for a namespaced slug whose last segment the provider advertises and expects the refusal to name that advertised slug. Co-Authored-By: Claude Opus 5.5 --- .../src/mcp/OrchestratorMcpService.test.ts | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.ts index f52ac95174277..89399a7ff1f8f 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.test.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts @@ -1833,6 +1833,58 @@ describe("OrchestratorMcpService provider resolution", () => { }), ); + it.effect("an unadvertised model refusal names the advertised slugs to retry with", () => + Effect.gen(function* () { + const codex = providerSnapshot({ + instanceId: codexInstanceId, + driver: ProviderDriverKind.make("codex"), + }); + const layerDependencies = Layer.mergeAll( + NodeServices.layer, + NodeCrypto.layer, + Layer.mock(ThreadManagementService.ThreadManagementService)({ + hasReceipt: () => Effect.succeed(false), + getThreadRecords: () => Effect.succeed(parentProjection([])), + }), + ServerSettings.layerTest(), + providerRegistryLayer([ + { + ...codex, + models: ["gpt-6.1-sol", "gpt-6.1-terra"].map((slug) => ({ + slug, + name: slug, + isCustom: false, + capabilities: null, + })), + }, + ]), + adapterRegistryLayer([codexInstanceId]), + Layer.mock(ProjectService.ProjectService)({}), + Layer.mock(SecretRequests.SecretRequests)({}), + Layer.mock(RemoteDelegation.RemoteDelegation)({}), + Layer.mock(ScheduledTaskService.ScheduledTaskService)({}), + ); + + yield* Effect.gen(function* () { + const service = yield* OrchestratorMcpService.OrchestratorMcpService; + const refusal = yield* service + .delegateTask(scope, { + task: "Summarize the diff.", + target: { providerInstanceId: codexInstanceId, model: "codemie/gpt-6.1-terra" }, + mode: "async", + clientRequestId: "delegate-unadvertised-model", + }) + .pipe(Effect.flip); + assert.equal(refusal.code, "model_unavailable"); + assert.include( + refusal.message.replaceAll("codemie/gpt-6.1-terra", ""), + "gpt-6.1-terra", + "the refusal names the advertised slug to retry with", + ); + }).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies)))); + }), + ); + it.effect("driver-only delegation skips an instance the project turned off", () => Effect.gen(function* () { const altInstanceId = ProviderInstanceId.make("codex-alt"); From b985946ba9cd109072b9547f8a2d9e6d391a34e4 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 6 Nov 2026 08:56:47 +0000 Subject: [PATCH 2/3] fix(server): delegate_task model refusal names advertised slugs to retry with delegate_task refused an unadvertised model with only "Model X is not advertised by provider Y.", so an agent that built a slug from prose had to call orchestrator_capabilities again before it could retry. The refusal now names advertised slugs whose last `/` segment matches the requested slug (case-insensitive). With no such match it lists up to LISTED_MODEL_LIMIT advertised slugs, current ones first, and says how many more there are and that orchestrator_capabilities with search finds them. Fixes pingdotgg/t3code#31890 Co-Authored-By: Claude Opus 5.5 --- .../src/mcp/OrchestratorMcpService.test.ts | 52 +++++++++++++++++++ apps/server/src/mcp/OrchestratorMcpService.ts | 22 +++++++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.ts index 89399a7ff1f8f..314cde53f902b 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.test.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts @@ -1885,6 +1885,58 @@ describe("OrchestratorMcpService provider resolution", () => { }), ); + it.effect("an unadvertised model with no close match lists a capped set of current slugs", () => + Effect.gen(function* () { + const codex = providerSnapshot({ + instanceId: codexInstanceId, + driver: ProviderDriverKind.make("codex"), + }); + const layerDependencies = Layer.mergeAll( + NodeServices.layer, + NodeCrypto.layer, + Layer.mock(ThreadManagementService.ThreadManagementService)({ + hasReceipt: () => Effect.succeed(false), + getThreadRecords: () => Effect.succeed(parentProjection([])), + }), + ServerSettings.layerTest(), + providerRegistryLayer([ + { + ...codex, + models: [ + { slug: "claude-opus-4-1", isLegacy: true }, + ...Array.from({ length: 9 }, (_, index) => ({ slug: `claude-opus-5-${index + 1}` })), + ].map((model) => ({ ...model, name: model.slug, isCustom: false, capabilities: null })), + }, + ]), + adapterRegistryLayer([codexInstanceId]), + Layer.mock(ProjectService.ProjectService)({}), + Layer.mock(SecretRequests.SecretRequests)({}), + Layer.mock(RemoteDelegation.RemoteDelegation)({}), + Layer.mock(ScheduledTaskService.ScheduledTaskService)({}), + ); + + yield* Effect.gen(function* () { + const service = yield* OrchestratorMcpService.OrchestratorMcpService; + const refusal = yield* service + .delegateTask(scope, { + task: "Summarize the diff.", + target: { providerInstanceId: codexInstanceId, model: "opus-5.5" }, + mode: "async", + clientRequestId: "delegate-unadvertised-model-listing", + }) + .pipe(Effect.flip); + assert.equal(refusal.code, "model_unavailable"); + assert.equal( + refusal.message, + "Model opus-5.5 is not advertised by provider codex. Advertised models: " + + "claude-opus-5-1, claude-opus-5-2, claude-opus-5-3, claude-opus-5-4, claude-opus-5-5, " + + "claude-opus-5-6, claude-opus-5-7, claude-opus-5-8 and 2 more; " + + "orchestrator_capabilities with search finds them.", + ); + }).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies)))); + }), + ); + it.effect("driver-only delegation skips an instance the project turned off", () => Effect.gen(function* () { const altInstanceId = ProviderInstanceId.make("codex-alt"); diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index 9d15408483a3e..4b777787e8f12 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -338,6 +338,26 @@ function listCapabilityModels(input: { return { listed, omitted: visible.length - listed.length }; } +/** Names advertised slugs to retry with: same last `/` segment first, else a short list. */ +function advertisedModelsHint(models: ReadonlyArray, requested: string) { + const lastSegment = (slug: string) => slug.slice(slug.lastIndexOf("/") + 1).toLowerCase(); + const wanted = lastSegment(requested); + const close = models.filter((model) => lastSegment(model.slug) === wanted); + if (close.length > 0) { + return `Did you mean ${close + .slice(0, LISTED_MODEL_LIMIT) + .map((model) => model.slug) + .join(", ")}?`; + } + const listed = models + .toSorted((a, b) => Number(a.isLegacy ?? false) - Number(b.isLegacy ?? false)) + .slice(0, LISTED_MODEL_LIMIT); + const omitted = models.length - listed.length; + return `Advertised models: ${listed.map((model) => model.slug).join(", ")}${ + omitted > 0 ? ` and ${omitted} more; orchestrator_capabilities with search finds them` : "" + }.`; +} + /** Option ids and allowed values are all a delegating agent needs; labels are UI copy. */ function capabilityModelOption(descriptor: ProviderOptionDescriptor): OrchestratorMcpModelOption { const defaultValue = getProviderOptionCurrentValue(descriptor); @@ -1430,7 +1450,7 @@ const make = Effect.gen(function* () { ) { return yield* failure( "model_unavailable", - `Model ${requestedModel} is not advertised by provider ${instanceId}.`, + `Model ${requestedModel} is not advertised by provider ${instanceId}. ${advertisedModelsHint(provider.models, requestedModel)}`, ); } From f38dc7ce73b08d5cbdeff0a0dfdc40faec6d4668 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 10 Nov 2026 21:20:47 +0000 Subject: [PATCH 3/3] test(server): cover both model refusal hints in one case AI-assisted; verified with the tests and tools listed above. --- .../src/mcp/OrchestratorMcpService.test.ts | 84 +++++-------------- 1 file changed, 21 insertions(+), 63 deletions(-) diff --git a/apps/server/src/mcp/OrchestratorMcpService.test.ts b/apps/server/src/mcp/OrchestratorMcpService.test.ts index 30527a9479f76..34624cbc3e6d5 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.test.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.test.ts @@ -1843,59 +1843,7 @@ describe("OrchestratorMcpService provider resolution", () => { }), ); - it.effect("an unadvertised model refusal names the advertised slugs to retry with", () => - Effect.gen(function* () { - const codex = providerSnapshot({ - instanceId: codexInstanceId, - driver: ProviderDriverKind.make("codex"), - }); - const layerDependencies = Layer.mergeAll( - NodeServices.layer, - NodeCrypto.layer, - Layer.mock(ThreadManagementService.ThreadManagementService)({ - hasReceipt: () => Effect.succeed(false), - getThreadRecords: () => Effect.succeed(parentProjection([])), - }), - ServerSettings.layerTest(), - providerRegistryLayer([ - { - ...codex, - models: ["gpt-6.1-sol", "gpt-6.1-terra"].map((slug) => ({ - slug, - name: slug, - isCustom: false, - capabilities: null, - })), - }, - ]), - adapterRegistryLayer([codexInstanceId]), - Layer.mock(ProjectService.ProjectService)({}), - Layer.mock(SecretRequests.SecretRequests)({}), - Layer.mock(RemoteDelegation.RemoteDelegation)({}), - Layer.mock(ScheduledTaskService.ScheduledTaskService)({}), - ); - - yield* Effect.gen(function* () { - const service = yield* OrchestratorMcpService.OrchestratorMcpService; - const refusal = yield* service - .delegateTask(scope, { - task: "Summarize the diff.", - target: { providerInstanceId: codexInstanceId, model: "codemie/gpt-6.1-terra" }, - mode: "async", - clientRequestId: "delegate-unadvertised-model", - }) - .pipe(Effect.flip); - assert.equal(refusal.code, "model_unavailable"); - assert.include( - refusal.message.replaceAll("codemie/gpt-6.1-terra", ""), - "gpt-6.1-terra", - "the refusal names the advertised slug to retry with", - ); - }).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies)))); - }), - ); - - it.effect("an unadvertised model with no close match lists a capped set of current slugs", () => + it.effect("an unadvertised model refusal names advertised slugs to retry with", () => Effect.gen(function* () { const codex = providerSnapshot({ instanceId: codexInstanceId, @@ -1927,17 +1875,27 @@ describe("OrchestratorMcpService provider resolution", () => { yield* Effect.gen(function* () { const service = yield* OrchestratorMcpService.OrchestratorMcpService; - const refusal = yield* service - .delegateTask(scope, { - task: "Summarize the diff.", - target: { providerInstanceId: codexInstanceId, model: "opus-5.5" }, - mode: "async", - clientRequestId: "delegate-unadvertised-model-listing", - }) - .pipe(Effect.flip); - assert.equal(refusal.code, "model_unavailable"); + const refuse = (model: string) => + service + .delegateTask(scope, { + task: "Summarize the diff.", + target: { providerInstanceId: codexInstanceId, model }, + mode: "async", + clientRequestId: `delegate-unadvertised-${model}`, + }) + .pipe(Effect.flip); + + const prefixed = yield* refuse("anthropic/claude-opus-5-3"); + assert.equal(prefixed.code, "model_unavailable"); + assert.equal( + prefixed.message, + "Model anthropic/claude-opus-5-3 is not advertised by provider codex. " + + "Did you mean claude-opus-5-3?", + ); + + const unmatched = yield* refuse("opus-5.5"); assert.equal( - refusal.message, + unmatched.message, "Model opus-5.5 is not advertised by provider codex. Advertised models: " + "claude-opus-5-1, claude-opus-5-2, claude-opus-5-3, claude-opus-5-4, claude-opus-5-5, " + "claude-opus-5-6, claude-opus-5-7, claude-opus-5-8 and 2 more; " +