Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/mcp/OrchestratorMcpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ const make = Effect.gen(function* () {
hasPendingChildRuns: false,
providerInstanceId: task.providerInstanceId,
model: task.model,
executedModel: null,
executedModel: task.executedModel ?? null,
summary: task.result,
resultContextTransferId: null,
latestTerminalRunId: null,
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/orchestration-v2/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10075,6 +10075,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
remoteChild,
status: command.status,
result: command.result,
...(command.executedModel === undefined ? {} : { executedModel: command.executedModel }),
completedAt: now,
updatedAt: now,
};
Expand Down
11 changes: 11 additions & 0 deletions apps/server/src/peer/RemoteDelegation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,11 @@ it.effect("a task's result is its own run's whole last reply, not a later run's"
expect(task?.result).toBe(
`Requested model gpt-5.4; the provider reported running gpt-5.4-mini.\n\n${long}`,
);
const status = yield* a.call("task_status", { taskId });
expect(status.structuredContent).toMatchObject({
status: "completed",
executedModel: "gpt-5.4-mini",
});
// Every wait was for the run the launch started.
const waits = yield* Ref.get(thread.waitedFor);
expect(waits.length).toBeGreaterThan(0);
Expand All @@ -1464,6 +1469,7 @@ it.effect("a task whose thread there waits on its own task ends with the answer
const delegated = yield* delegateToBox(a);

// The task's run there ends after delegating a review of its own.
yield* Ref.set(thread.executedModel, "gpt-5.4-mini");
yield* Ref.set(thread.nested, true);
yield* Ref.set(thread.reply, "Started a review; I will answer when it reports.");
yield* Ref.set(thread.status, "completed");
Expand All @@ -1481,6 +1487,11 @@ it.effect("a task whose thread there waits on its own task ends with the answer
status: "completed",
result: "The review found two issues; both are fixed.",
});
const status = yield* a.call("task_status", { taskId: delegated.taskId });
expect(status.structuredContent).toMatchObject({
status: "completed",
executedModel: null,
});
}),
).pipe(Effect.provide(NodeHttpServer.layerTest)),
);
Expand Down
18 changes: 13 additions & 5 deletions apps/server/src/peer/RemoteDelegation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ const make = Effect.gen(function* () {
result: string,
stoppedThere: "ran-out" | "stopped" | undefined,
stopCount?: number,
executedModel?: string,
) {
const attempt = yield* random.uuidV4();
yield* threads
Expand All @@ -551,6 +552,7 @@ const make = Effect.gen(function* () {
result,
...(stoppedThere === undefined ? {} : { stoppedThere }),
...(stopCount === undefined ? {} : { stopCount }),
...(executedModel === undefined ? {} : { executedModel }),
})
.pipe(
Effect.catch((error) =>
Expand Down Expand Up @@ -642,7 +644,8 @@ const make = Effect.gen(function* () {
afterPosition = read.nextPosition;
}
reply = error ?? reply;
if (reply === undefined) return undefined;
const executedModel = run?.executedModel ?? undefined;
if (reply === undefined) return { text: undefined, executedModel };
let text = reply.text ?? "";
let textOffset = reply.textTruncated ? (reply.nextTextOffset ?? null) : null;
while (textOffset !== null) {
Expand All @@ -657,7 +660,10 @@ const make = Effect.gen(function* () {
text += part.text ?? "";
textOffset = part.textTruncated ? (part.nextTextOffset ?? null) : null;
}
return run === undefined ? text : withExecutedModelNote(text, run.model, run.executedModel);
return {
text: run === undefined ? text : withExecutedModelNote(text, run.model, run.executedModel),
executedModel,
};
});

/**
Expand Down Expand Up @@ -823,8 +829,8 @@ const make = Effect.gen(function* () {
yield* complete(
parentThreadId,
taskId,
reply === undefined ? "failed" : "completed",
reply ?? "The thread in the linked environment has no run to follow.",
reply.text === undefined ? "failed" : "completed",
reply.text ?? "The thread in the linked environment has no run to follow.",
"ran-out",
);
return yield* settled(parentThreadId, taskId);
Expand Down Expand Up @@ -860,8 +866,10 @@ const make = Effect.gen(function* () {
parentThreadId,
taskId,
terminalStatus(resultRun.status),
result ?? noReply,
result.text ?? noReply,
"ran-out",
undefined,
result.executedModel,
);
return yield* settled(parentThreadId, taskId);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/src/orchestrationV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ export const OrchestrationV2Subagent = Schema.Struct({
title: Schema.NullOr(Schema.String),
model: Schema.NullOr(Schema.String),
modelSelection: Schema.optional(ModelSelection),
executedModel: Schema.optional(Schema.String),
completionWake: Schema.optional(Schema.Literals(["always", "settled_only"])),
completionDelivery: Schema.optional(OrchestrationV2DelegatedCompletionTaskDelivery),
// The run whose unfinished task was cancelled, committed with its Stop.
Expand Down Expand Up @@ -3692,6 +3693,7 @@ const OrchestrationV2InternalCommand = Schema.Union([
taskId: NodeId,
status: Schema.Literals(["completed", "failed", "cancelled", "interrupted"]),
result: Schema.String,
executedModel: Schema.optional(Schema.String),
/**
* `ran-out`: the run there ended by itself; `stopped`: a stop from here reached it. Either
* sets `remoteChild.stoppedThere` on a task this report completes. On a task already
Expand Down
Loading