Skip to content

Commit 457d420

Browse files
fix(server): a cut delivery run that asked a question counts as answered
Codex records an asynchronous question as the run's only output, so a restart that cut that run offered the same completion again. Questions and approval requests now count as the agent acting on the wake. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1f1b8e7 commit 457d420

2 files changed

Lines changed: 38 additions & 19 deletions

File tree

‎apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts‎

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ it.layer(Layer.merge(layerTest, ProviderContinuationRequests.layer))(
24022402

24032403
const finishFollowup = (input: {
24042404
readonly name: string;
2405-
readonly startedBy: "background-command" | "parent";
2405+
readonly startedBy: "background-command" | "parent" | "user";
24062406
/** The parent steers a message into the follow-up's run before it answers. */
24072407
readonly steeredByParent?: boolean;
24082408
readonly result: "repeat" | "new";
@@ -2520,11 +2520,15 @@ it.layer(Layer.merge(layerTest, ProviderContinuationRequests.layer))(
25202520
}
25212521
: {
25222522
type: "message.dispatch",
2523-
createdBy: "agent",
2524-
creationSource: "mcp",
25252523
commandId: CommandId.make(`command:${name}-followup`),
25262524
threadId: child.childThreadId,
2527-
senderThreadId: parentThreadId,
2525+
...(input.startedBy === "user"
2526+
? { createdBy: "user" as const, creationSource: "web" as const }
2527+
: {
2528+
createdBy: "agent" as const,
2529+
creationSource: "mcp" as const,
2530+
senderThreadId: parentThreadId,
2531+
}),
25282532
messageId,
25292533
text: "Check the same work again.",
25302534
attachments: [],
@@ -2675,11 +2679,11 @@ it.layer(Layer.merge(layerTest, ProviderContinuationRequests.layer))(
26752679
}),
26762680
);
26772681

2678-
it.effect("a parent-sent repeat still wakes", () =>
2682+
it.effect.each(["parent", "user"] as const)("a %s-sent repeat still wakes", (startedBy) =>
26792683
Effect.gen(function* () {
26802684
const { followup, delivery } = yield* finishFollowup({
2681-
name: "followup-parent-repeat",
2682-
startedBy: "parent",
2685+
name: `followup-${startedBy}-repeat`,
2686+
startedBy,
26832687
result: "repeat",
26842688
});
26852689
assert.equal(followup.completionDelivery?.state, "claimed");
@@ -3589,14 +3593,15 @@ it.layer(layerTest)("delegated tasks across a server restart", (it) => {
35893593
);
35903594

35913595
it.effect.each([
3592-
{ origin: "provider_native", state: "delivered" },
3593-
{ origin: "app_owned", state: "claimed" },
3594-
] as const)("a cut delivery run whose only item is a $origin subagent ends $state", (input) =>
3596+
{ item: "provider_native subagent", state: "delivered" },
3597+
{ item: "app_owned subagent", state: "claimed" },
3598+
{ item: "question", state: "delivered" },
3599+
] as const)("a cut delivery run whose only item is a $item ends $state", (input) =>
35953600
Effect.gen(function* () {
35963601
const orchestrator = yield* Orchestrator.OrchestratorV2;
35973602
const eventSink = yield* EventSink.EventSinkV2;
35983603
const now = yield* DateTime.now;
3599-
const name = `delivery-cut-${input.origin}`;
3604+
const name = `delivery-cut-${input.item.replace(" ", "-")}`;
36003605
const threadId = ThreadId.make(`thread:${name}`);
36013606
const runId = RunId.make(`run:${name}`);
36023607
const taskId = NodeId.make(`node:${name}-task`);
@@ -3659,14 +3664,26 @@ it.layer(layerTest)("delegated tasks across a server restart", (it) => {
36593664
startedAt: now,
36603665
completedAt: null,
36613666
updatedAt: now,
3662-
type: "subagent",
3663-
subagentId: NodeId.make(`node:${name}-launched`),
3664-
origin: input.origin,
3665-
driver,
3666-
providerInstanceId: modelSelection.instanceId,
3667-
childThreadId: null,
3668-
prompt: "Check the merged findings.",
3669-
result: null,
3667+
...(input.item === "question"
3668+
? {
3669+
type: "user_input_request" as const,
3670+
requestId: RuntimeRequestId.make(`request:${name}`),
3671+
questions: [],
3672+
responseMode: "message" as const,
3673+
}
3674+
: {
3675+
type: "subagent" as const,
3676+
subagentId: NodeId.make(`node:${name}-launched`),
3677+
origin:
3678+
input.item === "provider_native subagent"
3679+
? ("provider_native" as const)
3680+
: ("app_owned" as const),
3681+
driver,
3682+
providerInstanceId: modelSelection.instanceId,
3683+
childThreadId: null,
3684+
prompt: "Check the merged findings.",
3685+
result: null,
3686+
}),
36703687
},
36713688
},
36723689
runEvent({

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ const DELIVERY_ANSWER_TURN_ITEM_TYPES: ReadonlyArray<OrchestrationV2TurnItem["ty
769769
"file_search",
770770
"web_search",
771771
"dynamic_tool",
772+
"user_input_request",
773+
"approval_request",
772774
];
773775

774776
function delegatedCompletionWakeDetail(

0 commit comments

Comments
 (0)