Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

SteeringCompletion.integration.test.ts

711 lines26.9 KB

1import { assert, it } from "@effect/vitest";
2import {
3 CommandId,
4 MessageId,
5 EventId,
6 NodeId,
7 ProjectId,
8 ProviderDriverKind,
9 ProviderInstanceId,
10 ProviderThreadId,
11 ProviderTurnId,
12 ThreadId,
13 type ModelSelection,
14 type OrchestrationV2DomainEvent,
15} from "@t3tools/contracts";
16import * as DateTime from "effect/DateTime";
17import * as Deferred from "effect/Deferred";
18import * as Effect from "effect/Effect";
19import * as Fiber from "effect/Fiber";
20import * as Queue from "effect/Queue";
21import * as Stream from "effect/Stream";
22import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
23import * as EffectWorker from "./EffectWorker.ts";
24import * as EventSink from "./EventSink.ts";
25import * as Orchestrator from "./Orchestrator.ts";
26import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";
27import * as ProviderReplayHarness from "./testkit/ProviderReplayHarness.ts";
28import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
29import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
30​
31const driver = ProviderDriverKind.make("codex");
32const instanceId = ProviderInstanceId.make("codex");
33const modelSelection = { instanceId, model: "test-model" };
34​
35it.effect.each(
36 [false, true]
37 .flatMap((mailbox) =>
38 (
39 [
40 "before delivery",
41 "during delivery",
42 "before dispatch",
43 "after delivery",
44 "without native steering",
45 "with interrupting native steering",
46 "settled only",
47 ] as const
48 ).map((timing) => ({
49 mailbox,
50 timing,
51 label: mailbox ? "mailbox notification" : "steering",
52 })),
53 )
54 .filter(
55 ({ mailbox, timing }) =>
56 mailbox ||
57 (timing !== "without native steering" &&
58 timing !== "with interrupting native steering" &&
59 timing !== "settled only"),
60 ),
61)("delivers $label when completion wins $timing", ({ mailbox, timing }) =>
62 Effect.scoped(
63 Effect.gen(function* () {
64 const cwd = yield* checkpointWorkspace(`steering-completion-${timing.replaceAll(" ", "-")}`);
65 const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
66 const started: ProviderAdapter.ProviderAdapterV2TurnInput[] = [];
67 const steerEntered = yield* Deferred.make<void>();
68 const rejectSteer = yield* Deferred.make<void>();
69 let steerCalls = 0;
70 const capabilities = {
71 ...CodexProviderCapabilitiesV2,
72 turns: {
73 ...CodexProviderCapabilitiesV2.turns,
74 supportsActiveSteering: timing !== "without native steering",
75 activeSteeringInterruptsTools: timing === "with interrupting native steering",
76 },
77 };
78 const adapter: ProviderAdapter.ProviderAdapterV2["Service"] = {
79 instanceId,
80 driver,
81 getCapabilities: () => Effect.succeed(capabilities),
82 planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
83 openSession: (input) =>
84 Effect.gen(function* () {
85 const now = yield* DateTime.now;
86 return {
87 instanceId,
88 driver,
89 providerSessionId: input.providerSessionId,
90 providerSession: {
91 id: input.providerSessionId,
92 driver,
93 providerInstanceId: instanceId,
94 status: "ready",
95 cwd,
96 model: modelSelection.model,
97 capabilities,
98 createdAt: now,
99 updatedAt: now,
100 lastError: null,
101 },
102 events: Stream.fromQueue(events),
103 ensureThread: ({ threadId }) =>
104 Effect.succeed({
105 id: ProviderThreadId.make(`provider-thread:${threadId}`),
106 driver,
107 providerInstanceId: instanceId,
108 providerSessionId: input.providerSessionId,
109 appThreadId: threadId,
110 ownerNodeId: null,
111 nativeThreadRef: { driver, nativeId: "native-thread", strength: "strong" },
112 nativeConversationHeadRef: null,
113 status: "idle",
114 firstRunOrdinal: null,
115 lastRunOrdinal: null,
116 handoffIds: [],
117 forkedFrom: null,
118 createdAt: now,
119 updatedAt: now,
120 }),
121 resumeThread: ({ providerThread }) => Effect.succeed(providerThread),
122 startTurn: (turn) =>
123 Effect.gen(function* () {
124 started.push(turn);
125 yield* Queue.offer(events, {
126 type: "provider_turn.updated",
127 driver,
128 providerTurn: {
129 id: ProviderTurnId.make(`provider-turn:${turn.attemptId}`),
130 providerThreadId: turn.providerThread.id,
131 nodeId: turn.rootNodeId,
132 runAttemptId: turn.attemptId,
133 nativeTurnRef: {
134 driver,
135 nativeId: `native:${turn.attemptId}`,
136 strength: "strong",
137 },
138 ordinal: turn.providerTurnOrdinal,
139 status: "running",
140 startedAt: now,
141 completedAt: null,
142 },
143 });
144 }),
145 steerTurn: (turn) =>
146 Effect.gen(function* () {
147 steerCalls += 1;
148 if (timing === "after delivery") return;
149 yield* Deferred.succeed(steerEntered, undefined);
150 yield* Deferred.await(rejectSteer);
151 return yield* new ProviderAdapter.ProviderAdapterSteerRunError({
152 driver,
153 providerThreadId: turn.providerThread.id,
154 providerTurnId: turn.providerTurnId,
155 cause: "turn already completed",
156 });
157 }),
158 interruptTurn: () => Effect.void,
159 respondToRuntimeRequest: () => Effect.void,
160 readThreadSnapshot: () => Effect.die("unused"),
161 rollbackThread: () => Effect.die("unused"),
162 forkThread: () => Effect.die("unused"),
163 };
164 }),
165 };
166 yield* Effect.gen(function* () {
167 const orchestrator = yield* Orchestrator.OrchestratorV2;
168 const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
169 const threadId = ThreadId.make("thread:steering-completion");
170 const watch = (predicate: (event: OrchestrationV2DomainEvent) => boolean) =>
171 orchestrator.streamDomainEvents.pipe(
172 Stream.filter(predicate),
173 Stream.take(1),
174 Stream.runDrain,
175 Effect.forkScoped,
176 );
177 yield* orchestrator.dispatch({
178 type: "thread.create",
179 commandId: CommandId.make("create"),
180 threadId,
181 projectId: ProjectId.make("project:steering-completion"),
182 title: "Steering race",
183 modelSelection,
184 runtimeMode: "full-access",
185 interactionMode: "default",
186 branch: null,
187 worktreePath: cwd,
188 createdBy: "user",
189 creationSource: "web",
190 });
191 yield* orchestrator.dispatch({
192 type: "message.dispatch",
193 commandId: CommandId.make("first"),
194 threadId,
195 messageId: MessageId.make("message:first"),
196 text: "first",
197 attachments: [],
198 dispatchMode: { type: "start_immediately" },
199 createdBy: "user",
200 creationSource: "web",
201 });
202 const running = yield* watch(
203 (event) => event.type === "provider-turn.updated" && event.payload.status === "running",
204 );
205 yield* worker.drain();
206 yield* Fiber.join(running);
207 const first = started[0]!;
208 const messageId = MessageId.make("message:steering");
209 const taskId = NodeId.make("task:mailbox");
210 if (mailbox) {
211 const sink = yield* EventSink.EventSinkV2;
212 const current = yield* orchestrator.getThreadProjection(threadId);
213 const parentRun = current.runs.find((run) => run.id === first.runId)!;
214 const now = yield* DateTime.now;
215 yield* sink.write({
216 events: [
217 {
218 id: EventId.make("mailbox:cohort"),
219 type: "run.updated",
220 threadId,
221 runId: first.runId,
222 occurredAt: now,
223 payload: {
224 ...parentRun,
225 delegatedCompletion: {
226 disposition: "open",
227 nextGeneration: 2,
228 delivery: { generation: 1, messageId, taskIds: [taskId] },
229 },
230 },
231 },
232 {
233 id: EventId.make("mailbox:task"),
234 type: "subagent.updated",
235 threadId,
236 runId: first.runId,
237 nodeId: taskId,
238 occurredAt: now,
239 payload: {
240 id: taskId,
241 threadId,
242 runId: first.runId,
243 parentNodeId: first.rootNodeId,
244 origin: "app_owned",
245 createdBy: "agent",
246 driver,
247 providerInstanceId: instanceId,
248 providerThreadId: null,
249 childThreadId: null,
250 nativeTaskRef: null,
251 prompt: "Do background work",
252 title: "Background test",
253 model: null,
254 completionWake: timing === "settled only" ? "settled_only" : "always",
255 completionDelivery: { state: "claimed", observedByRunId: null },
256 status: "completed",
257 result: "done",
258 startedAt: now,
259 completedAt: now,
260 updatedAt: now,
261 },
262 },
263 ],
264 });
265 }
266 const dispatchSteer = orchestrator.dispatch({
267 type: "message.dispatch",
268 commandId: CommandId.make("steer"),
269 threadId,
270 messageId,
271 text: "fix the popover",
272 attachments: [
273 {
274 type: "image",
275 id: "steering-screenshot",
276 name: "image.png",
277 mimeType: "image/png",
278 sizeBytes: 10,
279 },
280 ],
281 dispatchMode: mailbox
282 ? { type: "queue_after_active" }
283 : { type: "steer_active", targetRunId: first.runId },
284 createdBy: mailbox ? "agent" : "user",
285 creationSource: mailbox ? "server" : "web",
286 ...(mailbox
287 ? {
288 delegatedCompletion: {
289 parentRunId: first.runId,
290 generation: 1,
291 taskIds: [taskId],
292 },
293 }
294 : {}),
295 });
296 if (timing !== "before dispatch") yield* dispatchSteer;
297 if (timing === "after delivery") yield* worker.drain();
298 const delivery =
299 timing === "during delivery" ? yield* worker.runOnce.pipe(Effect.forkScoped) : null;
300 if (delivery !== null) yield* Deferred.await(steerEntered);
301 const completed = yield* watch(
302 (event) =>
303 event.type === "run.updated" &&
304 event.payload.id === first.runId &&
305 event.payload.status === "waiting",
306 );
307 const projection = yield* orchestrator.getThreadProjection(threadId);
308 const turn = projection.providerTurns[0]!;
309 yield* Queue.offer(events, {
310 type: "provider_turn.updated",
311 driver,
312 providerTurn: { ...turn, status: "completed", completedAt: yield* DateTime.now },
313 });
314 yield* Queue.offer(events, {
315 type: "turn.terminal",
316 driver,
317 providerThreadId: turn.providerThreadId,
318 providerTurnId: turn.id,
319 runOrdinal: first.runOrdinal,
320 status: "completed",
321 failure: null,
322 threadDisposition: "reusable",
323 });
324 yield* Fiber.join(completed);
325 if (delivery !== null) {
326 yield* Deferred.succeed(rejectSteer, undefined);
327 yield* Fiber.join(delivery);
328 }
329 if (timing === "before dispatch") yield* dispatchSteer;
330 yield* worker.drain();
331 yield* orchestrator.resumeQueuedRuns;
332 yield* worker.drain();
333 if (timing === "after delivery") {
334 assert.equal(steerCalls, 1);
335 assert.equal(started.length, 1);
336 if (mailbox) {
337 const delivered = yield* orchestrator.getThreadProjection(threadId);
338 assert.equal(delivered.subagents[0]?.completionDelivery?.state, "delivered");
339 assert.equal(delivered.subagents[0]?.completionDelivery?.observedByRunId, null);
340 assert.equal(delivered.runs[0]?.delegatedCompletion?.delivery, null);
341 assert.equal(
342 delivered.turnItems.filter((item) => item.type === "notification").length,
343 1,
344 );
345 yield* orchestrator.dispatch({
346 type: "notification.delivery.accept",
347 commandId: CommandId.make("duplicate-acceptance"),
348 threadId,
349 messageId,
350 });
351 yield* worker.drain();
352 assert.equal(steerCalls, 1);
353 yield* orchestrator.dispatch({
354 type: "delegated_task.completion-delivery.acknowledge",
355 commandId: CommandId.make("read-result"),
356 parentThreadId: threadId,
357 taskId,
358 observedByRunId: first.runId,
359 });
360 const acknowledged = yield* orchestrator.getThreadProjection(threadId);
361 assert.equal(acknowledged.subagents[0]?.completionDelivery?.state, "acknowledged");
362 }
363 return;
364 }
365 assert.equal(started.length, 2);
366 assert.equal(started[1]?.message.messageId, messageId);
367 if (mailbox) assert.include(started[1]?.message.text ?? "", String(taskId));
368 else assert.equal(started[1]?.message.text, "fix the popover");
369 assert.deepEqual(started[1]?.message.attachments, [
370 {
371 type: "image",
372 id: "steering-screenshot",
373 name: "image.png",
374 mimeType: "image/png",
375 sizeBytes: 10,
376 },
377 ]);
378 assert.equal(steerCalls, timing === "during delivery" ? 1 : 0);
379 const final = yield* orchestrator.getThreadProjection(threadId);
380 assert.equal(final.messages.filter((message) => message.id === messageId).length, 1);
381 assert.equal(
382 final.messages.find((message) => message.id === messageId)?.runId,
383 started[1]?.runId,
384 );
385 assert.equal(
386 final.turnItems.filter((item) =>
387 mailbox
388 ? item.type === "notification"
389 : item.type === "user_message" && item.messageId === messageId,
390 ).length,
391 1,
392 );
393 yield* worker.drain();
394 assert.equal(started.length, 2);
395 }).pipe(
396 Effect.provide(
397 ProviderReplayHarness.layerWithRegistry(
398 { name: `steering-completion-${timing}` },
399 ProviderAdapterRegistry.layerSingle(adapter),
400 { runEffectWorker: false },
401 ),
402 ),
403 );
404 }),
405 ),
406);
407​
408// A changed selection the provider applies on its next turn waits there as the
409// thread's saved selection. That holds for a provider that can restart the
410// turn (Codex) too: restarting it would end the turn's native subagents.
411const runSelection = {
412 instanceId,
413 model: "test-model",
414 options: [{ id: "effort", value: "xhigh" }],
415};
416const composerSelection = {
417 ...runSelection,
418 options: [...runSelection.options, { id: "fastMode", value: false }],
419};
420​
421const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function* (
422 name: string,
423 canRestart = false,
424) {
425 const cwd = yield* checkpointWorkspace(name);
426 const events = yield* Queue.unbounded<ProviderAdapter.ProviderAdapterV2Event>();
427 const started: ProviderAdapter.ProviderAdapterV2TurnInput[] = [];
428 const steered: string[] = [];
429 const capabilities = {
430 ...CodexProviderCapabilitiesV2,
431 turns: {
432 ...CodexProviderCapabilitiesV2.turns,
433 supportsActiveSteering: true,
434 supportsSteeringByInterruptRestart: canRestart,
435 },
436 };
437 const adapter: ProviderAdapter.ProviderAdapterV2["Service"] = {
438 instanceId,
439 driver,
440 getCapabilities: () => Effect.succeed(capabilities),
441 planSelectionTransition: () => Effect.succeed({ type: "apply_on_next_turn" }),
442 openSession: (input) =>
443 Effect.gen(function* () {
444 const now = yield* DateTime.now;
445 return {
446 instanceId,
447 driver,
448 providerSessionId: input.providerSessionId,
449 providerSession: {
450 id: input.providerSessionId,
451 driver,
452 providerInstanceId: instanceId,
453 status: "ready",
454 cwd,
455 model: runSelection.model,
456 capabilities,
457 createdAt: now,
458 updatedAt: now,
459 lastError: null,
460 },
461 events: Stream.fromQueue(events),
462 ensureThread: ({ threadId }) =>
463 Effect.succeed({
464 id: ProviderThreadId.make(`provider-thread:${threadId}`),
465 driver,
466 providerInstanceId: instanceId,
467 providerSessionId: input.providerSessionId,
468 appThreadId: threadId,
469 ownerNodeId: null,
470 nativeThreadRef: { driver, nativeId: "native-thread", strength: "strong" },
471 nativeConversationHeadRef: null,
472 status: "idle",
473 firstRunOrdinal: null,
474 lastRunOrdinal: null,
475 handoffIds: [],
476 forkedFrom: null,
477 createdAt: now,
478 updatedAt: now,
479 }),
480 resumeThread: ({ providerThread }) => Effect.succeed(providerThread),
481 startTurn: (turn) =>
482 Effect.gen(function* () {
483 started.push(turn);
484 yield* Queue.offer(events, {
485 type: "provider_turn.updated",
486 driver,
487 providerTurn: {
488 id: ProviderTurnId.make(`provider-turn:${turn.attemptId}`),
489 providerThreadId: turn.providerThread.id,
490 nodeId: turn.rootNodeId,
491 runAttemptId: turn.attemptId,
492 nativeTurnRef: {
493 driver,
494 nativeId: `native:${turn.attemptId}`,
495 strength: "strong",
496 },
497 ordinal: turn.providerTurnOrdinal,
498 status: "running",
499 startedAt: now,
500 completedAt: null,
501 },
502 });
503 }),
504 steerTurn: (turn) =>
505 Effect.sync(() => {
506 steered.push(turn.message.text);
507 }),
508 interruptTurn: () => Effect.void,
509 respondToRuntimeRequest: () => Effect.void,
510 readThreadSnapshot: () => Effect.die("unused"),
511 rollbackThread: () => Effect.die("unused"),
512 forkThread: () => Effect.die("unused"),
513 };
514 }),
515 };
516 const layer = ProviderReplayHarness.layerWithRegistry(
517 { name },
518 ProviderAdapterRegistry.layerSingle(adapter),
519 { runEffectWorker: false },
520 );
521 // Creates the thread and starts its first turn on `runSelection`.
522 const startFirstTurn = Effect.gen(function* () {
523 const orchestrator = yield* Orchestrator.OrchestratorV2;
524 const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
525 const threadId = ThreadId.make(`thread:${name}`);
526 yield* orchestrator.dispatch({
527 type: "thread.create",
528 commandId: CommandId.make("create"),
529 threadId,
530 projectId: ProjectId.make(`project:${name}`),
531 title: "Steer with changed options",
532 modelSelection: runSelection,
533 runtimeMode: "full-access",
534 interactionMode: "default",
535 branch: null,
536 worktreePath: cwd,
537 createdBy: "user",
538 creationSource: "web",
539 });
540 const running = yield* orchestrator.streamDomainEvents.pipe(
541 Stream.filter(
542 (event) => event.type === "provider-turn.updated" && event.payload.status === "running",
543 ),
544 Stream.take(1),
545 Stream.runDrain,
546 Effect.forkScoped,
547 );
548 yield* orchestrator.dispatch({
549 type: "message.dispatch",
550 commandId: CommandId.make("first"),
551 threadId,
552 messageId: MessageId.make("message:first"),
553 text: "first",
554 attachments: [],
555 modelSelection: runSelection,
556 dispatchMode: { type: "start_immediately" },
557 createdBy: "user",
558 creationSource: "web",
559 });
560 yield* worker.drain();
561 yield* Fiber.join(running);
562 return threadId;
563 });
564 return { events, started, steered, layer, startFirstTurn };
565});
566​
567it.effect.each([{ canRestart: false }, { canRestart: true }])(
568 "steers a changed turn-scoped selection into the running turn (canRestart=$canRestart)",
569 ({ canRestart }) =>
570 Effect.scoped(
571 Effect.gen(function* () {
572 const { started, steered, layer, startFirstTurn } = yield* nextTurnSelectionHarness(
573 `steering-selection-change-${canRestart}`,
574 canRestart,
575 );
576 yield* Effect.gen(function* () {
577 const orchestrator = yield* Orchestrator.OrchestratorV2;
578 const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
579 const threadId = yield* startFirstTurn;
580 const steer = (id: string, selection: ModelSelection) =>
581 orchestrator
582 .dispatch({
583 type: "message.dispatch",
584 commandId: CommandId.make(id),
585 threadId,
586 messageId: MessageId.make(`message:${id}`),
587 text: id,
588 attachments: [],
589 modelSelection: selection,
590 dispatchMode: { type: "steer_active", targetRunId: started[0]!.runId },
591 createdBy: "user",
592 creationSource: "web",
593 })
594 .pipe(Effect.andThen(worker.drain()));
595​
596 yield* steer("steer-changed", composerSelection);
597 const changed = yield* orchestrator.getThreadProjection(threadId);
598 assert.deepEqual(steered, ["steer-changed"]);
599 assert.equal(started.length, 1);
600 assert.lengthOf(changed.attempts, 1);
601 assert.equal(changed.runs[0]?.status, "running");
602 assert.deepEqual(changed.runs[0]?.modelSelection, runSelection);
603 assert.deepEqual(changed.thread.modelSelection, composerSelection);
604​
605 // Choosing the running run's selection again replaces the saved choice.
606 yield* steer("steer-reverted", runSelection);
607 const reverted = yield* orchestrator.getThreadProjection(threadId);
608 assert.deepEqual(steered, ["steer-changed", "steer-reverted"]);
609 assert.lengthOf(reverted.attempts, 1);
610 assert.deepEqual(reverted.thread.modelSelection, runSelection);
611​
612 // The saved choice moves to another instance while the run keeps going.
613 // Steering with the run's selection brings the thread's instance back too.
614 const otherSelection = {
615 instanceId: ProviderInstanceId.make("codex-work"),
616 model: "other",
617 };
618 const sink = yield* EventSink.EventSinkV2;
619 yield* sink.write({
620 events: [
621 {
622 id: EventId.make("switched-away"),
623 type: "thread.provider-switched",
624 threadId,
625 providerInstanceId: otherSelection.instanceId,
626 occurredAt: yield* DateTime.now,
627 payload: {
628 ...reverted.thread,
629 providerInstanceId: otherSelection.instanceId,
630 modelSelection: otherSelection,
631 },
632 },
633 ],
634 });
635 yield* steer("steer-back", runSelection);
636 const back = yield* orchestrator.getThreadProjection(threadId);
637 assert.deepEqual(steered, ["steer-changed", "steer-reverted", "steer-back"]);
638 assert.equal(back.thread.providerInstanceId, instanceId);
639 assert.deepEqual(back.thread.modelSelection, runSelection);
640 }).pipe(Effect.provide(layer));
641 }),
642 ),
643);
644​
645it.effect("starts a steer that missed the turn on the saved next-turn selection", () =>
646 Effect.scoped(
647 Effect.gen(function* () {
648 const { events, started, steered, layer, startFirstTurn } = yield* nextTurnSelectionHarness(
649 "steering-selection-follow-up",
650 );
651 yield* Effect.gen(function* () {
652 const orchestrator = yield* Orchestrator.OrchestratorV2;
653 const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
654 const threadId = yield* startFirstTurn;
655 const first = started[0]!;
656 yield* orchestrator.dispatch({
657 type: "message.dispatch",
658 commandId: CommandId.make("steer"),
659 threadId,
660 messageId: MessageId.make("message:steer"),
661 text: "late steer",
662 attachments: [],
663 modelSelection: composerSelection,
664 dispatchMode: { type: "steer_active", targetRunId: first.runId },
665 createdBy: "user",
666 creationSource: "web",
667 });
668 // The turn ends before the worker delivers the steer, so the steer
669 // becomes a follow-up turn.
670 const settled = yield* orchestrator.streamDomainEvents.pipe(
671 Stream.filter(
672 (event) =>
673 event.type === "run.updated" &&
674 event.payload.id === first.runId &&
675 event.payload.status === "waiting",
676 ),
677 Stream.take(1),
678 Stream.runDrain,
679 Effect.forkScoped,
680 );
681 const turn = (yield* orchestrator.getThreadProjection(threadId)).providerTurns[0]!;
682 yield* Queue.offer(events, {
683 type: "provider_turn.updated",
684 driver,
685 providerTurn: { ...turn, status: "completed", completedAt: yield* DateTime.now },
686 });
687 yield* Queue.offer(events, {
688 type: "turn.terminal",
689 driver,
690 providerThreadId: turn.providerThreadId,
691 providerTurnId: turn.id,
692 runOrdinal: first.runOrdinal,
693 status: "completed",
694 failure: null,
695 threadDisposition: "reusable",
696 });
697 yield* Fiber.join(settled);
698 yield* worker.drain();
699 yield* orchestrator.resumeQueuedRuns;
700 yield* worker.drain();
701​
702 const projection = yield* orchestrator.getThreadProjection(threadId);
703 assert.deepEqual(steered, []);
704 assert.equal(started.length, 2);
705 assert.equal(started[1]?.message.messageId, MessageId.make("message:steer"));
706 assert.deepEqual(started[1]?.modelSelection, composerSelection);
707 assert.deepEqual(projection.thread.modelSelection, composerSelection);
708 }).pipe(Effect.provide(layer));
709 }),
710 ),
711);