@devries-cameron20 / t3code Mirror · read-only / commits / 35b88636d4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 12:15 UTC

fix(server): delegate_task model refusals name slugs to retry with (#31905)

Julius Marminge committed Nov 14, 2026 at 19:14 UTC 35b88636d431dafdc84820621f4073aaa178ca0b
3 files changed +86 -2
apps/server/src/mcp/OrchestratorMcpService.test.ts
+62
@@ -2430,6 +2430,68 @@ describe("OrchestratorMcpService provider resolution", () => {
2430 }),
2431 );
2432
2433 + it.effect("an unadvertised model refusal names advertised slugs to retry with", () =>
2434 + Effect.gen(function* () {
2435 + const codex = providerSnapshot({
2436 + instanceId: codexInstanceId,
2437 + driver: ProviderDriverKind.make("codex"),
2438 + });
2439 + const layerDependencies = Layer.mergeAll(
2440 + NodeServices.layer,
2441 + NodeCrypto.layer,
2442 + Layer.mock(ThreadManagementService.ThreadManagementService)({
2443 + hasReceipt: () => Effect.succeed(false),
2444 + getThreadRecords: () => Effect.succeed(parentProjection([])),
2445 + }),
2446 + ServerSettings.layerTest(),
2447 + providerRegistryLayer([
2448 + {
2449 + ...codex,
2450 + models: [
2451 + { slug: "claude-opus-4-1", isLegacy: true },
2452 + ...Array.from({ length: 9 }, (_, index) => ({ slug: `claude-opus-5-${index + 1}` })),
2453 + ].map((model) => ({ ...model, name: model.slug, isCustom: false, capabilities: null })),
2454 + },
2455 + ]),
2456 + adapterRegistryLayer([codexInstanceId]),
2457 + Layer.mock(ProjectService.ProjectService)({}),
2458 + Layer.mock(SecretRequests.SecretRequests)({}),
2459 + Layer.mock(RemoteDelegation.RemoteDelegation)({}),
2460 + Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
2461 + );
2462 +
2463 + yield* Effect.gen(function* () {
2464 + const service = yield* OrchestratorMcpService.OrchestratorMcpService;
2465 + const refuse = (model: string) =>
2466 + service
2467 + .delegateTask(scope, {
2468 + task: "Summarize the diff.",
2469 + target: { providerInstanceId: codexInstanceId, model },
2470 + mode: "async",
2471 + clientRequestId: `delegate-unadvertised-${model}`,
2472 + })
2473 + .pipe(Effect.flip);
2474 +
2475 + const prefixed = yield* refuse("anthropic/claude-opus-5-3");
2476 + assert.equal(prefixed.code, "model_unavailable");
2477 + assert.equal(
2478 + prefixed.message,
2479 + "Model anthropic/claude-opus-5-3 is not advertised by provider codex. " +
2480 + "Did you mean claude-opus-5-3?",
2481 + );
2482 +
2483 + const unmatched = yield* refuse("opus-5.5");
2484 + assert.equal(
2485 + unmatched.message,
2486 + "Model opus-5.5 is not advertised by provider codex. Advertised models: " +
2487 + "claude-opus-5-1, claude-opus-5-2, claude-opus-5-3, claude-opus-5-4, claude-opus-5-5, " +
2488 + "claude-opus-5-6, claude-opus-5-7, claude-opus-5-8 and 2 more; " +
2489 + "orchestrator_capabilities with search finds them.",
2490 + );
2491 + }).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies))));
2492 + }),
2493 + );
2494 +
2495 it.effect("driver-only delegation skips an instance the project turned off", () =>
2496 Effect.gen(function* () {
2497 const altInstanceId = ProviderInstanceId.make("codex-alt");
apps/server/src/mcp/OrchestratorMcpService.ts
+21 -1
@@ -354,6 +354,26 @@ function listCapabilityModels(input: {
354 return { listed, omitted: visible.length - listed.length };
355 }
356
357 +/** Names advertised slugs to retry with: same last `/` segment first, else a short list. */
358 +function advertisedModelsHint(models: ReadonlyArray<ServerProviderModel>, requested: string) {
359 + const lastSegment = (slug: string) => slug.slice(slug.lastIndexOf("/") + 1).toLowerCase();
360 + const wanted = lastSegment(requested);
361 + const close = models.filter((model) => lastSegment(model.slug) === wanted);
362 + if (close.length > 0) {
363 + return `Did you mean ${close
364 + .slice(0, LISTED_MODEL_LIMIT)
365 + .map((model) => model.slug)
366 + .join(", ")}?`;
367 + }
368 + const listed = models
369 + .toSorted((a, b) => Number(a.isLegacy ?? false) - Number(b.isLegacy ?? false))
370 + .slice(0, LISTED_MODEL_LIMIT);
371 + const omitted = models.length - listed.length;
372 + return `Advertised models: ${listed.map((model) => model.slug).join(", ")}${
373 + omitted > 0 ? ` and ${omitted} more; orchestrator_capabilities with search finds them` : ""
374 + }.`;
375 +}
376 +
377 /** Option ids and allowed values are all a delegating agent needs; labels are UI copy. */
378 function capabilityModelOption(descriptor: ProviderOptionDescriptor): OrchestratorMcpModelOption {
379 const defaultValue = getProviderOptionCurrentValue(descriptor);
@@ -377,7 +397,7 @@ export const requireAdvertisedModel = (provider: ServerProvider, model: string)
397 ? Effect.fail(
398 failure(
399 "model_unavailable",
380 - `Model ${model} is not advertised by provider ${provider.instanceId}.`,
400 + `Model ${model} is not advertised by provider ${provider.instanceId}. ${advertisedModelsHint(provider.models, model)}`,
401 ),
402 )
403 : Effect.void;
apps/server/src/mcp/toolkits/project/handlers.test.ts
+3 -1
@@ -399,7 +399,9 @@ it.effect("a launch with a model its provider does not advertise creates no thre
399 ] as const) {
400 expect(yield* launchWith(instanceId, model)).toMatchObject({
401 code: "model_unavailable",
402 - message: `Model ${model} is not advertised by provider ${instanceId}.`,
402 + message: expect.stringContaining(
403 + `Model ${model} is not advertised by provider ${instanceId}. Advertised models: `,
404 + ),
405 });
406 }
407 expect(launched).toHaveLength(0);