The best way to control Claude Code, Codex and more from any computer or phone
fix(server): changing a task's wake policy no longer reverts a checkpointed parent run (#25662)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 3, 2026 at 10:29 UTC
abf8998b66040cc869339f307be189dd7e3595c7
2 files changed
+50
-21
apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
+45
-20
@@ -158,7 +158,7 @@ const seedParentWithTerminalTask = (input: {
158
readonly runId: RunId;
159
readonly rootNodeId: NodeId;
160
readonly taskId: NodeId;
161
- readonly deliveryState: "delivered" | "claimed" | "acknowledged" | "disposed";
161
+ readonly deliveryState: "pending" | "delivered" | "claimed" | "acknowledged" | "disposed";
162
readonly completionWake?: "always" | "settled_only";
163
readonly deliveryTaskIds?: ReadonlyArray<NodeId>;
164
readonly parentRunStatus?: "running" | "completed";
@@ -1049,6 +1049,7 @@ it.layer(layerTest)("delegated completion delivery repairs", (it) => {
1049
{ command: "acknowledge", before: "running", after: "failed", capture: false },
1050
{ command: "acknowledge", before: "waiting", after: "completed", capture: true },
1051
{ command: "accept", before: "waiting", after: "completed", capture: true },
1052
+ { command: "wake-policy", before: "running", after: "completed", capture: true },
1053
] as const)(
1054
"keeps a $after run that settled between $command's read and commit",
1055
({ command, before, after, capture }) =>
@@ -1062,14 +1063,20 @@ it.layer(layerTest)("delegated completion delivery repairs", (it) => {
1063
const taskId = NodeId.make(`node:${race}-task`);
1064
const checkpointId = CheckpointId.make(`checkpoint:${race}`);
1065
const messageId = MessageId.make(`message:delegated-delivery:${threadId}`);
1066
+ const commandType = {
1067
+ acknowledge: "delegated_task.completion-delivery.acknowledge",
1068
+ accept: "notification.delivery.accept",
1069
+ "wake-policy": "delegated_task.wake-policy",
1070
+ }[command];
1071
yield* seedParentWithTerminalTask({
1072
threadId,
1073
projectId: ProjectId.make(`project:${race}`),
1074
runId,
1075
rootNodeId: NodeId.make(`node:${race}-root`),
1076
taskId,
1071
- deliveryState: "claimed",
1072
- deliveryTaskIds: [taskId],
1077
+ ...(command === "wake-policy"
1078
+ ? { deliveryState: "pending" }
1079
+ : { deliveryState: "claimed", deliveryTaskIds: [taskId] }),
1080
now,
1081
});
1082
const parent = (yield* orchestrator.getThreadProjection(threadId)).runs[0]!;
@@ -1110,18 +1117,18 @@ it.layer(layerTest)("delegated completion delivery repairs", (it) => {
1117
const { delegatedCompletion: _cohort, ...settledRun } = parent;
1118
const commit = sink.commitCommand;
1119
let settled = false;
1120
+ let planned: OrchestrationV2Run["delegatedCompletion"];
1121
yield* Effect.acquireUseRelease(
1122
Effect.sync(() =>
1123
vi.spyOn(sink, "commitCommand").mockImplementation((input) =>
1124
Effect.gen(function* () {
1117
- if (
1118
- !settled &&
1119
- input.commandType ===
1120
- (command === "accept"
1121
- ? "notification.delivery.accept"
1122
- : "delegated_task.completion-delivery.acknowledge")
1123
- ) {
1125
+ if (!settled && input.commandType === commandType) {
1126
settled = true;
1127
+ const plannedRun = input.events.find((event) => event.type === "run.updated");
1128
+ planned =
1129
+ plannedRun?.type === "run.updated"
1130
+ ? plannedRun.payload.delegatedCompletion
1131
+ : undefined;
1132
// The provider turn ends (or its checkpoint lands) after the command read the run.
1133
yield* commit({
1134
commandId: CommandId.make(`command:${race}`),
@@ -1159,13 +1166,21 @@ it.layer(layerTest)("delegated completion delivery repairs", (it) => {
1166
threadId,
1167
messageId,
1168
}
1162
- : {
1163
- type: "delegated_task.completion-delivery.acknowledge",
1164
- commandId: CommandId.make(`command:${race}:task-status`),
1165
- parentThreadId: threadId,
1166
- taskId,
1167
- observedByRunId: runId,
1168
- },
1169
+ : command === "wake-policy"
1170
+ ? {
1171
+ type: "delegated_task.wake-policy",
1172
+ commandId: CommandId.make(`command:${race}:wake-policy`),
1173
+ parentThreadId: threadId,
1174
+ taskId,
1175
+ completionWake: "always",
1176
+ }
1177
+ : {
1178
+ type: "delegated_task.completion-delivery.acknowledge",
1179
+ commandId: CommandId.make(`command:${race}:task-status`),
1180
+ parentThreadId: threadId,
1181
+ taskId,
1182
+ observedByRunId: runId,
1183
+ },
1184
),
1185
(spy) => Effect.sync(() => spy.mockRestore()),
1186
);
@@ -1173,12 +1188,22 @@ it.layer(layerTest)("delegated completion delivery repairs", (it) => {
1188
const finished = yield* orchestrator.getThreadProjection(threadId);
1189
assert.equal(
1190
finished.subagents.find((row) => row.id === taskId)?.completionDelivery?.state,
1176
- command === "accept" ? "delivered" : "acknowledged",
1191
+ { acknowledge: "acknowledged", accept: "delivered", "wake-policy": "claimed" }[command],
1192
);
1193
const run = finished.runs.find((candidate) => candidate.id === runId)!;
1194
assert.deepEqual(
1180
- { status: run.status, completedAt: run.completedAt, checkpointId: run.checkpointId },
1181
- { status: after, completedAt: now, checkpointId: capture ? checkpointId : null },
1195
+ {
1196
+ status: run.status,
1197
+ completedAt: run.completedAt,
1198
+ checkpointId: run.checkpointId,
1199
+ delegatedCompletion: run.delegatedCompletion,
1200
+ },
1201
+ {
1202
+ status: after,
1203
+ completedAt: now,
1204
+ checkpointId: capture ? checkpointId : null,
1205
+ delegatedCompletion: planned,
1206
+ },
1207
);
1208
}),
1209
);
apps/server/src/orchestration-v2/Orchestrator.ts
+5
-1
@@ -8586,6 +8586,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
8586
payload: completionPlan.message,
8587
});
8588
}
8589
+ return completionPlan.parentRun?.id;
8590
});
8591
8592
const dispatchCreatedThreadRecord = Effect.fn("orchestrationV2.dispatch.createdThreadRecord")(
@@ -13413,7 +13414,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
13414
yield* dispatchRemoteDelegatedTaskStop(command, events);
13415
break;
13416
case "delegated_task.wake-policy":
13416
- yield* dispatchDelegatedTaskWakePolicy(command, events);
13417
+ updateDelegatedCompletionOnlyRunId = yield* dispatchDelegatedTaskWakePolicy(
13418
+ command,
13419
+ events,
13420
+ );
13421
break;
13422
case "delegated_task.completion-delivery.acknowledge":
13423
case "delegated_task.completion-delivery.dispose":