@devries-cameron20 / t3code-1 / commits / c45cbd742b
Fork 0

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

fix(server): delegated Claude tasks report the model that ran (#27753)

Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

shivam committed Nov 9, 2026 at 12:16 UTC c45cbd742b6bbe7e9594ca60ffedcab81a3e2dde
12 files changed +161 -15
apps/server/src/mcp/OrchestratorMcpService.activity.test.ts
+8
@@ -136,6 +136,7 @@ it("readThread preserves caller access errors and prefers activity-run status ov
136 makeRun({ id: cancelledRunId, ordinal: 2, status: "cancelled" }),
137 ],
138 visibleTurnItems: [],
139 + providerTurns: [],
140 runtimeRequests: [],
141 messages: [],
142 contextTransfers: [],
@@ -222,6 +223,7 @@ it("readThread pages cut-off text without splitting an emoji across pages", asyn
223 }),
224 runs: [makeRun({ id: activeRunId, ordinal: 1, status: "running" })],
225 visibleTurnItems: [],
226 + providerTurns: [],
227 runtimeRequests: [],
228 messages: [],
229 contextTransfers: [],
@@ -312,6 +314,7 @@ it("taskStatus returns task.providerInstanceId rather than the driver kind", asy
314 }),
315 runs: [makeRun({ id: activeRunId, ordinal: 1, status: "running" })],
316 visibleTurnItems: [],
317 + providerTurns: [],
318 runtimeRequests: [],
319 messages: [],
320 contextTransfers: [],
@@ -365,6 +368,7 @@ it("taskStatus returns task.providerInstanceId rather than the driver kind", asy
368 }),
369 ],
370 visibleTurnItems: [],
371 + providerTurns: [],
372 runtimeRequests: [],
373 messages: [],
374 contextTransfers: [
@@ -438,6 +442,7 @@ it("readThread and sendToThread reach threads in other projects", async () => {
442 return parentRuns;
443 },
444 visibleTurnItems: [],
445 + providerTurns: [],
446 runtimeRequests: [],
447 messages: [],
448 contextTransfers: [],
@@ -474,6 +479,7 @@ it("readThread and sendToThread reach threads in other projects", async () => {
479 },
480 },
481 ],
482 + providerTurns: [],
483 runtimeRequests: [],
484 messages: [],
485 contextTransfers: [],
@@ -670,6 +676,7 @@ it("requestSecret saves a pasted value to a file without opening a card", async
676 }),
677 runs: [{ ...makeRun({ id: activeRunId, ordinal: 1, status: "running" }), rootNodeId: taskId }],
678 visibleTurnItems: [],
679 + providerTurns: [],
680 runtimeRequests: [],
681 messages: [],
682 contextTransfers: [],
@@ -791,6 +798,7 @@ it("requestSecret returns the unsaved note for a declined, cancelled or timed-ou
798 card === undefined
799 ? []
800 : [{ type: "secret_request", id: card.turnItemId, secretStatus: outcome }],
801 + providerTurns: [],
802 runtimeRequests: [],
803 messages: [],
804 contextTransfers: [],
apps/server/src/mcp/OrchestratorMcpService.test.ts
+25 -1
@@ -145,6 +145,7 @@ describe("OrchestratorMcpService", () => {
145 turnItems: [],
146 subagents: [],
147 providerThreads: [],
148 + providerTurns: [],
149 runtimeRequests: [],
150 } as unknown as OrchestrationV2ThreadProjection;
151 let hasNestedWork = true;
@@ -288,6 +289,7 @@ describe("OrchestratorMcpService", () => {
289 messages: [],
290 subagents: [],
291 providerThreads: [],
292 + providerTurns: [],
293 runtimeRequests: [],
294 turnItems: [],
295 } as unknown as OrchestrationV2ThreadProjection;
@@ -385,6 +387,7 @@ describe("OrchestratorMcpService", () => {
387 messages: [],
388 subagents: [],
389 providerThreads: [],
390 + providerTurns: [],
391 runtimeRequests: pendingRequest ? [{ status: "pending" }] : [],
392 nodes: [],
393 turnItems: [],
@@ -485,6 +488,7 @@ describe("OrchestratorMcpService", () => {
488 messages: [],
489 subagents: [],
490 providerThreads: [],
491 + providerTurns: [],
492 runtimeRequests: [],
493 } as unknown as OrchestrationV2ThreadProjection;
494 const layerDependencies = Layer.mergeAll(
@@ -575,6 +579,7 @@ describe("OrchestratorMcpService", () => {
579 messages: [],
580 subagents: [],
581 providerThreads: [],
582 + providerTurns: [],
583 runtimeRequests: [],
584 turnItems: [],
585 } as unknown as OrchestrationV2ThreadProjection;
@@ -678,6 +683,7 @@ describe("OrchestratorMcpService", () => {
683 messages: [],
684 subagents: [],
685 providerThreads: [],
686 + providerTurns: [],
687 runtimeRequests: [],
688 } as unknown as OrchestrationV2ThreadProjection;
689 const layerDependencies = Layer.mergeAll(
@@ -761,6 +767,7 @@ describe("OrchestratorMcpService", () => {
767 messages: [],
768 subagents: [],
769 providerThreads: [],
770 + providerTurns: [],
771 runtimeRequests: [],
772 } as unknown as OrchestrationV2ThreadProjection;
773 const layerDependencies = Layer.mergeAll(
@@ -850,6 +857,7 @@ describe("OrchestratorMcpService", () => {
857 messages: [],
858 subagents: [],
859 providerThreads: [],
860 + providerTurns: [],
861 runtimeRequests: [],
862 } as unknown as OrchestrationV2ThreadProjection;
863 const layerDependencies = Layer.mergeAll(
@@ -973,6 +981,7 @@ describe("OrchestratorMcpService", () => {
981 appOwnedTask("node:mcp-cancel-grandchild-below", childThreadId, grandchildThreadId),
982 ],
983 providerThreads: [],
984 + providerTurns: [],
985 runtimeRequests: [],
986 },
987 ],
@@ -997,6 +1006,7 @@ describe("OrchestratorMcpService", () => {
1006 messages: [],
1007 subagents: [],
1008 providerThreads: [],
1009 + providerTurns: [],
1010 runtimeRequests: [],
1011 },
1012 ],
@@ -1233,6 +1243,7 @@ describe("OrchestratorMcpService provider resolution", () => {
1243 messages: [],
1244 subagents: [],
1245 providerThreads: [],
1246 + providerTurns: [],
1247 runtimeRequests: [],
1248 turnItems: [],
1249 } as unknown as OrchestrationV2ThreadProjection;
@@ -3060,9 +3071,18 @@ describe("OrchestratorMcpService provider resolution", () => {
3071 ordinal: 1,
3072 status: "running",
3073 modelSelection: runSelection,
3074 + activeAttemptId: "attempt:mcp-restarted-child",
3075 },
3076 ]
3077 : [],
3078 + // Claude ran the requested Opus on Sonnet.
3079 + providerTurns: [
3080 + {
3081 + runAttemptId: "attempt:mcp-restarted-child",
3082 + ordinal: 1,
3083 + model: "claude-sonnet-4-6",
3084 + },
3085 + ],
3086 } as unknown as OrchestrationV2ThreadProjection),
3087 ),
3088 }),
@@ -3076,11 +3096,15 @@ describe("OrchestratorMcpService provider resolution", () => {
3096 );
3097 yield* Effect.gen(function* () {
3098 const service = yield* OrchestratorMcpService.OrchestratorMcpService;
3079 - for (const selection of [runSelection, threadSelection]) {
3099 + for (const [selection, executedModel] of [
3100 + [runSelection, "claude-sonnet-4-6"],
3101 + [threadSelection, null],
3102 + ] as const) {
3103 const result = yield* service.taskStatus(scope, taskId);
3104 assert.equal(result.providerInstanceId, selection.instanceId);
3105 assert.equal(result.model, selection.model);
3106 assert.deepEqual(result.options, selection.options);
3107 + assert.equal(result.executedModel, executedModel);
3108 hasRun = false;
3109 }
3110 }).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(dependencies))));
apps/server/src/mcp/OrchestratorMcpService.ts
+28 -5
@@ -63,6 +63,7 @@ import {
63 type ServerProviderModel,
64 ThreadId,
65 isOrchestrationV2WorkActive,
66 + latestProviderTurnForAttempt,
67 resolveProjectProviderInstanceEnabled,
68 SECRET_REQUEST_UNSAVED_NOTE,
69 } from "@t3tools/contracts";
@@ -614,7 +615,7 @@ function pageIncludesTerminalTaskResult(input: {
615 readonly task: OrchestrationV2Subagent;
616 readonly target: Pick<
617 OrchestrationV2ThreadProjection,
617 - "thread" | "runs" | "contextTransfers" | "messages" | "turnItems"
618 + "thread" | "runs" | "contextTransfers" | "messages" | "turnItems" | "providerTurns"
619 >;
620 readonly maxChars: number;
621 }): boolean {
@@ -875,13 +876,26 @@ function threadDetail(
876 };
877 }
878
878 -function threadRun(run: OrchestrationV2Run): OrchestratorMcpThreadRun {
879 +function runExecutedModel(
880 + projection: Pick<OrchestrationV2ThreadProjection, "providerTurns">,
881 + run: Pick<OrchestrationV2Run, "activeAttemptId"> | undefined,
882 +): string | null {
883 + return run === undefined
884 + ? null
885 + : (latestProviderTurnForAttempt(projection.providerTurns, run.activeAttemptId)?.model ?? null);
886 +}
887 +
888 +function threadRun(
889 + projection: Pick<OrchestrationV2ThreadProjection, "providerTurns">,
890 + run: OrchestrationV2Run,
891 +): OrchestratorMcpThreadRun {
892 return {
893 runId: run.id,
894 ordinal: run.ordinal,
895 status: run.status,
896 providerInstanceId: run.modelSelection.instanceId,
897 model: run.modelSelection.model,
898 + executedModel: runExecutedModel(projection, run),
899 requestedAt: DateTime.formatIso(run.requestedAt),
900 startedAt: run.startedAt === null ? null : DateTime.formatIso(run.startedAt),
901 completedAt: run.completedAt === null ? null : DateTime.formatIso(run.completedAt),
@@ -1280,10 +1294,11 @@ const make = Effect.gen(function* () {
1294 const records =
1295 parent === undefined
1296 ? threadManagement
1283 - .getProjectThreadRecords(input, ["runs", "runtimeRequests"])
1297 + .getProjectThreadRecords(input, ["runs", "providerTurns", "runtimeRequests"])
1298 .pipe(Effect.map((target) => ({ ...target, contextTransfers: [] })))
1299 : threadManagement.getProjectThreadRecords(input, [
1300 "runs",
1301 + "providerTurns",
1302 "runtimeRequests",
1303 "contextTransfers",
1304 ]);
@@ -1509,6 +1524,7 @@ const make = Effect.gen(function* () {
1524 "contextTransfers",
1525 "subagents",
1526 "providerThreads",
1527 + "providerTurns",
1528 "runtimeRequests",
1529 "nodes",
1530 ],
@@ -1601,7 +1617,12 @@ const make = Effect.gen(function* () {
1617 : null;
1618 const resultContextTransferId = resultTransfer?.id ?? null;
1619 const latestTerminalResultContextTransferId = resultTransferForRun(terminalRun)?.id ?? null;
1604 - const modelSelection = childRun?.modelSelection ??
1620 + const executionRun =
1621 + task.result === null
1622 + ? (taskResultRun ?? childRun)
1623 + : (childControls.runs.find((run) => run.id === resultTransfer?.sourcePoint.runId) ??
1624 + childRun);
1625 + const modelSelection = executionRun?.modelSelection ??
1626 childControls.thread.modelSelection ?? {
1627 instanceId: task.providerInstanceId,
1628 model: task.model,
@@ -1620,6 +1641,7 @@ const make = Effect.gen(function* () {
1641 hasPendingChildRuns: hasPendingChildRuns(childProjection, childRun),
1642 providerInstanceId: modelSelection.instanceId,
1643 model: modelSelection.model,
1644 + executedModel: runExecutedModel(childControls, executionRun),
1645 options: modelSelection.options ?? [],
1646 summary: derivedResult,
1647 resultContextTransferId,
@@ -1790,6 +1812,7 @@ const make = Effect.gen(function* () {
1812 hasPendingChildRuns: false,
1813 providerInstanceId: task.providerInstanceId,
1814 model: task.model,
1815 + executedModel: null,
1816 summary: task.result,
1817 resultContextTransferId: null,
1818 latestTerminalRunId: null,
@@ -3130,7 +3153,7 @@ const make = Effect.gen(function* () {
3153 recentRuns: target.runs
3154 .toSorted((left, right) => right.ordinal - left.ordinal)
3155 .slice(0, input.runLimit ?? DEFAULT_THREAD_RUN_LIMIT)
3133 - .map(threadRun),
3156 + .map((run) => threadRun(target, run)),
3157 items: page.map((row) =>
3158 timelineItem({
3159 row,
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+13 -3
@@ -2970,11 +2970,15 @@ describe("ClaudeAdapterV2 background wake turns", () => {
2970 uuid: "00000000-0000-4000-8000-000000000101",
2971 session_id: WAKE_NATIVE_SESSION,
2972 });
2973 - const makeAssistantTextFrame = (input: { readonly uuid: string; readonly text: string }) =>
2973 + const makeAssistantTextFrame = (input: {
2974 + readonly uuid: string;
2975 + readonly text: string;
2976 + readonly model?: string;
2977 + }) =>
2978 claudeSdkFrame({
2979 type: "assistant",
2980 message: {
2977 - model: "claude-sonnet-4-6",
2981 + model: input.model ?? "claude-sonnet-4-6",
2982 id: `msg_${input.uuid}`,
2983 type: "message",
2984 role: "assistant",
@@ -6838,7 +6842,12 @@ describe("ClaudeAdapterV2 background wake turns", () => {
6842 }),
6843 );
6844 yield* Queue.offerAll(harness.sdkMessages, [
6841 - makeAssistantTextFrame({ uuid: mainUuid, text: "Delegating." }),
6845 + // Claude reports the model it ran, which can differ from the one requested.
6846 + makeAssistantTextFrame({
6847 + uuid: mainUuid,
6848 + text: "Delegating.",
6849 + model: "claude-opus-4-5-20251101",
6850 + }),
6851 makeAssistantErrorFrame({
6852 uuid: "00000000-0000-4000-8000-000000000642",
6853 error: undefined,
@@ -6850,6 +6859,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
6859
6860 const providerTurn = lastProviderTurn(harness.events);
6861 assert.equal(providerTurn.nativeTurnRef?.nativeId, mainUuid);
6862 + assert.equal(providerTurn.model, "claude-opus-4-5");
6863 const rolledBack = yield* harness.runtime.rollbackThread({
6864 providerThread: harness.providerThread,
6865 target: {
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+12
@@ -189,6 +189,7 @@ import {
189 type ClaudeModelCatalog,
190 getClaudeCatalogModelCapabilities,
191 resolveClaudeModelSlug,
192 + resolveClaudeReportedModelSlug,
193 scopeClaudeModelCatalog,
194 } from "../../provider/ClaudeModelCatalog.ts";
195 import {
@@ -4398,6 +4399,8 @@ interface ActiveClaudeTurnContext {
4399 nativeWakeStarted: boolean;
4400 gatedFramesBeforeEcho: number;
4401 readonly heldRootFrames: Array<SDKMessage>;
4402 + // Claude can run another model than requested, such as when an organization disallows it.
4403 + executedModel: string | undefined;
4404 }
4405
4406 interface ActiveClaudeProviderRetry {
@@ -5498,6 +5501,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
5501 startedAt: context.startedAt,
5502 completedAt: null,
5503 tokenUsage,
5504 + ...(context.executedModel === undefined ? {} : { model: context.executedModel }),
5505 },
5506 });
5507 });
@@ -6008,6 +6012,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
6012 status: input.status,
6013 startedAt: input.context.startedAt,
6014 completedAt: input.completedAt,
6015 + ...(input.context.executedModel === undefined
6016 + ? {}
6017 + : { model: input.context.executedModel }),
6018 });
6019
6020 const buildToolCallArtifacts = (input: {
@@ -9134,6 +9141,10 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
9141 // CLI notices and API errors arrive as assistant messages from "<synthetic>".
9142 if (message.message.model && message.message.model !== "<synthetic>") {
9143 context.rootModels.add(message.message.model);
9144 + context.executedModel = resolveClaudeReportedModelSlug(
9145 + modelCatalog,
9146 + message.message.model,
9147 + );
9148 }
9149 // Subagent uuids exist only in the sidechain transcript, so resume and fork cannot target them.
9150 context.nativeMessageCursor = message.uuid;
@@ -11262,6 +11273,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
11273 nativeWakeStarted: false,
11274 gatedFramesBeforeEcho: 0,
11275 heldRootFrames: [],
11276 + executedModel: undefined,
11277 };
11278 const attachTurn = Effect.gen(function* () {
11279 querySession.lastTurn = context;
apps/server/src/orchestration-v2/SubagentProjection.test.ts
+8
@@ -413,6 +413,14 @@ it("orders a task's assistant messages by turn item, not by timestamps", () => {
413 assert.equal(result.text, "All steps passed.");
414 assert.equal(result.messageId, report.message.id);
415 assert.equal(result.turnItemId, report.turnItem.id);
416 + const reported = { runAttemptId: run.activeAttemptId, ordinal: 1, model: "gpt-5.4-mini" };
417 + assert.equal(
418 + subagentResultForRun(
419 + { ...projection, messages: [report.message], providerTurns: [reported as never] },
420 + run,
421 + ).text,
422 + "Requested model gpt-5.4; the provider reported running gpt-5.4-mini.\n\nAll steps passed.",
423 + );
424 });
425
426 it.effect("ends an orphaned native subagent's node when only its record already ended", () =>
apps/server/src/peer/RemoteDelegation.test.ts
+16 -2
@@ -100,6 +100,8 @@ interface BoxThread {
100 readonly laterError: Ref.Ref<string | null>;
101 /** A later run's reply, after the task's own, as a follow-up message would leave. */
102 readonly laterReply: Ref.Ref<string | null>;
103 + /** The model the provider there reported running the task's run. */
104 + readonly executedModel: Ref.Ref<string | null>;
105 /** The run each wait asked for, in order. */
106 readonly waitedFor: Ref.Ref<ReadonlyArray<RunId | undefined>>;
107 /** The thread's run ends with a task of its own still running, whose result wakes it again. */
@@ -145,6 +147,7 @@ const makeBoxThread = Effect.gen(function* () {
147 error: yield* Ref.make<string | null>(null),
148 laterError: yield* Ref.make<string | null>(null),
149 laterReply: yield* Ref.make<string | null>(null),
150 + executedModel: yield* Ref.make<string | null>(null),
151 waitedFor: yield* Ref.make<ReadonlyArray<RunId | undefined>>([]),
152 nested: yield* Ref.make(false),
153 nestedWaiting: yield* Deferred.make<void>(),
@@ -226,6 +229,7 @@ const boxToolkitLayer = (thread: BoxThread) => {
229 ordinal: 1,
230 status,
231 modelSelection,
232 + activeAttemptId: "attempt:box",
233 requestedAt: DateTime.makeUnsafe(0),
234 startedAt: DateTime.makeUnsafe(0),
235 completedAt: null,
@@ -235,9 +239,16 @@ const boxToolkitLayer = (thread: BoxThread) => {
239 const shell = yield* shellOf(threadId);
240 const status = yield* Ref.get(thread.status);
241 const runless = yield* Ref.get(thread.runless);
242 + const model = yield* Ref.get(thread.executedModel);
243 return shell === null
244 ? (null as never)
240 - : { ...idleThreadProjection(shell), runs: runless ? [] : [runOf(status)] };
245 + : {
246 + ...idleThreadProjection(shell),
247 + runs: runless ? [] : [runOf(status)],
248 + providerTurns: (model === null
249 + ? []
250 + : [{ runAttemptId: "attempt:box", ordinal: 1, model }]) as never,
251 + };
252 });
253 // One record per command id, as its receipt replays a repeat.
254 const recordStop = (commandId: string, kind: "interrupt" | "thread.stop" | "delegated-tasks") =>
@@ -1264,11 +1275,14 @@ it.effect("a task's result is its own run's whole last reply, not a later run's"
1275 const long = "x".repeat(45_000);
1276 yield* Ref.set(thread.reply, long);
1277 yield* Ref.set(thread.laterReply, "Someone else asked a follow-up.");
1278 + yield* Ref.set(thread.executedModel, "gpt-5.4-mini");
1279 yield* Ref.set(thread.status, "completed");
1280 yield* Deferred.succeed(thread.finished, undefined);
1281 const task = yield* taskResult(a, taskId);
1282 expect(task?.status).toBe("completed");
1271 - expect(task?.result).toBe(long);
1283 + expect(task?.result).toBe(
1284 + `Requested model gpt-5.4; the provider reported running gpt-5.4-mini.\n\n${long}`,
1285 + );
1286 // Every wait was for the run the launch started.
1287 const waits = yield* Ref.get(thread.waitedFor);
1288 expect(waits.length).toBeGreaterThan(0);
apps/server/src/peer/RemoteDelegation.ts
+7 -1
@@ -5,6 +5,7 @@ import {
5 OrchestratorMcpFailure,
6 type OrchestratorMcpDelegateTaskInput,
7 type OrchestratorMcpTaskCancelResult,
8 + type OrchestratorMcpThreadRun,
9 type OrchestratorMcpThreadTimelineItem,
10 type OrchestrationV2RemoteTaskChild,
11 type OrchestrationV2Subagent,
@@ -24,6 +25,7 @@ import * as Schedule from "effect/Schedule";
25 import * as Scope from "effect/Scope";
26 import * as Stream from "effect/Stream";
27 import type * as Tool from "effect/ai/Tool";
28 +import { withExecutedModelNote } from "@t3tools/provider-core/server/subagentProjection";
29
30 import type * as McpInvocationContext from "../mcp/McpInvocationContext.ts";
31 import { ProjectToolkit } from "../mcp/toolkits/project/tools.ts";
@@ -435,6 +437,7 @@ const make = Effect.gen(function* () {
437 * The last reply `runId` gave on the task's thread there, which is its
438 * result, read whole however long it is. A failed run prefers its error
439 * from the activity view over an earlier reply, without taking another run's.
440 + * Led by a note when its provider reported running another model than it asked for.
441 */
442 const lastReply = Effect.fn("RemoteDelegation.lastReply")(function* (
443 scope: ThreadScope,
@@ -445,13 +448,16 @@ const make = Effect.gen(function* () {
448 let reply: OrchestratorMcpThreadTimelineItem | undefined;
449 let error: OrchestratorMcpThreadTimelineItem | undefined;
450 let afterPosition: number | undefined;
451 + let run: OrchestratorMcpThreadRun | undefined;
452 while (true) {
453 const read = yield* forwarding.readThread(scope, remote.environmentId, {
454 threadId: remote.threadId,
455 view: failed ? "activity" : "messages",
456 limit: 100,
457 + runLimit: 50,
458 ...(afterPosition === undefined ? {} : { afterPosition }),
459 });
460 + run ??= read.recentRuns.find((candidate) => candidate.runId === runId);
461 reply =
462 read.items.findLast(
463 (item) => item.type === "assistant_message" && (runId === null || item.runId === runId),
@@ -481,7 +487,7 @@ const make = Effect.gen(function* () {
487 text += part.text ?? "";
488 textOffset = part.textTruncated ? (part.nextTextOffset ?? null) : null;
489 }
484 - return text;
490 + return run === undefined ? text : withExecutedModelNote(text, run.model, run.executedModel);
491 });
492
493 /**
apps/server/src/provider/ClaudeModelCatalog.ts
+13
@@ -239,6 +239,19 @@ export function resolveClaudeModelSlug(catalog: ClaudeModelCatalog, slugOrAlias:
239 return resolveClaudeCatalogModel(catalog, slugOrAlias)?.model.slug ?? slugOrAlias;
240 }
241
242 +/** Claude reports dated IDs, such as `claude-opus-4-5-20251101`, that the catalog may not list. */
243 +export function resolveClaudeReportedModelSlug(
244 + catalog: ClaudeModelCatalog,
245 + reported: string,
246 +): string {
247 + return (
248 + (
249 + resolveClaudeCatalogModel(catalog, reported) ??
250 + resolveClaudeCatalogModel(catalog, reported.replace(/-\d{8}$/, ""))
251 + )?.model.slug ?? reported
252 + );
253 +}
254 +
255 export function getClaudeCatalogModelCapabilities(
256 catalog: ClaudeModelCatalog,
257 slugOrAlias: string | null | undefined,
packages/contracts/src/orchestrationV2.ts
+2
@@ -1202,6 +1202,8 @@ export const OrchestrationV2ProviderTurn = Schema.Struct({
1202 completedAt: Schema.NullOr(Schema.DateTimeUtc),
1203 tokenUsage: Schema.optional(OrchestrationV2ProviderTurnTokenUsage),
1204 turnTokenUsage: Schema.optional(TurnTokenUsage),
1205 + /** The model the provider reported running this turn's root agent, which can differ from the requested one. */
1206 + model: Schema.optional(TrimmedNonEmptyString),
1207 });
1208 export type OrchestrationV2ProviderTurn = typeof OrchestrationV2ProviderTurn.Type;
1209
packages/contracts/src/orchestratorMcp.ts
+8
@@ -202,6 +202,12 @@ export const ORCHESTRATOR_MCP_RUNNING_TASK_NEXT =
202 "Completion wakes this thread, so end your turn. Do not wait on it or poll it.";
203 const OrchestratorMcpRunningTaskNext = Schema.Literal(ORCHESTRATOR_MCP_RUNNING_TASK_NEXT);
204
205 +// Optional: linked environments on older versions omit it.
206 +const OrchestratorMcpExecutedModel = Schema.NullOr(Schema.String).annotate({
207 + description:
208 + "Model the provider reported running, or null when unavailable. Can differ from the requested `model`.",
209 +});
210 +
211 export const OrchestratorMcpDelegateTaskResult = Schema.Struct({
212 taskId: NodeId,
213 /** Null for a task that runs in a linked environment; see `remoteChild`. */
@@ -222,6 +228,7 @@ export const OrchestratorMcpDelegateTaskResult = Schema.Struct({
228 latestTerminalResultContextTransferId: Schema.NullOr(ContextTransferId),
229 providerInstanceId: ProviderInstanceId,
230 model: Schema.NullOr(Schema.String),
231 + executedModel: Schema.optional(OrchestratorMcpExecutedModel),
232 options: Schema.optional(Schema.Array(ProviderOptionSelection)),
233 summary: Schema.NullOr(Schema.String),
234 resultContextTransferId: Schema.NullOr(ContextTransferId),
@@ -463,6 +470,7 @@ export const OrchestratorMcpThreadRun = Schema.Struct({
470 status: OrchestrationV2RunStatus,
471 providerInstanceId: ProviderInstanceId,
472 model: Schema.String,
473 + executedModel: Schema.optional(OrchestratorMcpExecutedModel),
474 requestedAt: IsoDateTime,
475 startedAt: Schema.NullOr(IsoDateTime),
476 completedAt: Schema.NullOr(IsoDateTime),
packages/provider-core/src/server/subagentProjection.ts
+21 -3
@@ -22,7 +22,7 @@ import { backgroundWorkHoldsCompletion } from "@t3tools/shared/orchestrationV2Pe
22 import { runRanAfter } from "@t3tools/shared/orchestrationV2ThreadError";
23 import * as DateTime from "effect/DateTime";
24 import * as Effect from "effect/Effect";
25 -import { isOrchestrationV2WorkActive } from "@t3tools/contracts";
25 +import { isOrchestrationV2WorkActive, latestProviderTurnForAttempt } from "@t3tools/contracts";
26
27 function trimmed(value: string | null | undefined): string | undefined {
28 const result = value?.trim();
@@ -176,8 +176,19 @@ export function makeSubagentConversationArtifacts(input: {
176 return { message, turnItem };
177 }
178
179 +/** A delegated result, led by a note when the provider reported running another model than requested. */
180 +export function withExecutedModelNote(
181 + result: string,
182 + requestedModel: string,
183 + executedModel: string | null | undefined,
184 +): string {
185 + return executedModel == null || executedModel === requestedModel
186 + ? result
187 + : `Requested model ${requestedModel}; the provider reported running ${executedModel}.\n\n${result}`;
188 +}
189 +
190 export function subagentResultForRun(
180 - projection: Pick<OrchestrationV2ThreadProjection, "messages" | "turnItems">,
191 + projection: Pick<OrchestrationV2ThreadProjection, "messages" | "turnItems" | "providerTurns">,
192 run: OrchestrationV2Run,
193 ): {
194 readonly text: string;
@@ -223,8 +234,15 @@ export function subagentResultForRun(
234 (run.status === "completed"
235 ? "Child task completed without an assistant result."
236 : `Child task ended with status ${run.status}.`);
237 + const executedModel = latestProviderTurnForAttempt(
238 + projection.providerTurns,
239 + run.activeAttemptId,
240 + )?.model;
241 return {
227 - text,
242 + text:
243 + executedModel === undefined
244 + ? text
245 + : withExecutedModelNote(text, run.modelSelection.model, executedModel),
246 messageId: failure === undefined ? (message?.id ?? turnItem?.messageId ?? null) : null,
247 turnItemId: failure?.id ?? turnItem?.id ?? null,
248 };