Skip to content

Commit 4e42d75

Browse files
test(server): cover the unscoped send in the follow-up delivery table
AI-assisted; verified with the tests and tools listed above.
1 parent 0f26ac8 commit 4e42d75

1 file changed

Lines changed: 2 additions & 85 deletions

File tree

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

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,7 +2575,8 @@ it.layer(Layer.merge(layerTest, ProviderContinuationRequests.layer))(
25752575
creationSource: outcome === "failed" ? "web" : "mcp",
25762576
commandId: CommandId.make(`command:followup-send-${outcome}`),
25772577
threadId: child.childThreadId,
2578-
senderThreadId: parentThreadId,
2578+
// `t3 thread send` and unscoped MCP sessions carry no sender thread.
2579+
...(outcome === "completed" ? {} : { senderThreadId: parentThreadId }),
25792580
messageId,
25802581
text: "Check the same work again.",
25812582
attachments: [],
@@ -2804,90 +2805,6 @@ it.layer(Layer.merge(layerTest, ProviderContinuationRequests.layer))(
28042805
}),
28052806
);
28062807

2807-
it.effect("tracks an unscoped MCP send to a finished child as a follow-up", () =>
2808-
Effect.gen(function* () {
2809-
const orchestrator = yield* Orchestrator.OrchestratorV2;
2810-
const eventSink = yield* EventSink.EventSinkV2;
2811-
const requests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
2812-
const now = yield* DateTime.now;
2813-
const parentThreadId = ThreadId.make("thread:unscoped-followup");
2814-
const projectId = ProjectId.make("project:unscoped-followup");
2815-
const parentRunId = RunId.make("run:unscoped-followup");
2816-
const rootNodeId = NodeId.make("node:unscoped-followup");
2817-
yield* seedParentWithTerminalTask({
2818-
threadId: parentThreadId,
2819-
projectId,
2820-
runId: parentRunId,
2821-
rootNodeId,
2822-
taskId: NodeId.make("node:unscoped-followup-seed"),
2823-
deliveryState: "acknowledged",
2824-
now,
2825-
});
2826-
const child = yield* seedRestartCancelledChild({
2827-
parentThreadId,
2828-
projectId,
2829-
parentRunId,
2830-
rootNodeId,
2831-
name: "unscoped-followup-child",
2832-
completionWake: "always",
2833-
continuationPending: false,
2834-
runStatus: "completed",
2835-
now,
2836-
});
2837-
yield* orchestrator.recoverDelegatedTasks;
2838-
let firstWake = yield* requests.take;
2839-
while (firstWake.threadId !== parentThreadId) firstWake = yield* requests.take;
2840-
yield* orchestrator.dispatch({
2841-
type: "delegated_task.completion-delivery.acknowledge",
2842-
commandId: CommandId.make("command:unscoped-followup-ack"),
2843-
parentThreadId,
2844-
taskId: child.taskId,
2845-
observedByRunId: parentRunId,
2846-
});
2847-
const parentRun = (yield* orchestrator.getThreadProjection(parentThreadId)).runs.find(
2848-
(run) => run.id === parentRunId,
2849-
)!;
2850-
yield* eventSink.write({
2851-
commandId: reconcileCommandId("unscoped-followup-parent-finished"),
2852-
events: [
2853-
{
2854-
id: EventId.make("event:unscoped-followup-parent-finished"),
2855-
type: "run.updated",
2856-
threadId: parentThreadId,
2857-
runId: parentRunId,
2858-
occurredAt: now,
2859-
payload: { ...parentRun, status: "completed", completedAt: now },
2860-
},
2861-
],
2862-
});
2863-
// `t3 thread send` and other MCP sessions without a thread scope carry no sender.
2864-
const messageId = MessageId.make("message:unscoped-followup");
2865-
yield* orchestrator.dispatch({
2866-
type: "message.dispatch",
2867-
createdBy: "agent",
2868-
creationSource: "mcp",
2869-
commandId: CommandId.make("command:unscoped-followup-send"),
2870-
threadId: child.childThreadId,
2871-
messageId,
2872-
text: "Check the same work again.",
2873-
attachments: [],
2874-
dispatchMode: { type: "start_immediately" },
2875-
});
2876-
const run = (yield* orchestrator.getThreadProjection(child.childThreadId)).runs.find(
2877-
(row) => row.userMessageId === messageId,
2878-
)!;
2879-
assert.isDefined(
2880-
run.delegatedTaskId,
2881-
"the child's follow-up run is not tracked as a delegated task on its parent",
2882-
);
2883-
const followup = (yield* orchestrator.getThreadProjection(parentThreadId)).subagents.find(
2884-
(task) => task.id === run.delegatedTaskId,
2885-
);
2886-
assert.equal(followup?.childThreadId, child.childThreadId);
2887-
assert.equal(followup?.completionWake, "always");
2888-
}),
2889-
);
2890-
28912808
it.effect("tracks a child's usage-limit auto-resume as a follow-up", () =>
28922809
Effect.gen(function* () {
28932810
const orchestrator = yield* Orchestrator.OrchestratorV2;

0 commit comments

Comments
 (0)