Skip to content

Commit ebf9980

Browse files
committed
fix(server): preserve queued model settings when steering
1 parent 1eb4071 commit ebf9980

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8308,7 +8308,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
83088308
events,
83098309
effects,
83108310
projection,
8311-
modelSelection: projection.thread.modelSelection,
8311+
modelSelection: queuedRun.modelSelection,
83128312
targetRunId: command.targetRunId,
83138313
messageId: queuedMessage.id,
83148314
text: queuedMessage.text,

‎apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,58 @@ it.effect(
759759
),
760760
);
761761

762+
it.effect("preserves a queued message's model options when promoting it to a steer", () =>
763+
Effect.scoped(
764+
Effect.gen(function* () {
765+
const { started, steered, layer, startFirstTurn } = yield* nextTurnSelectionHarness(
766+
"steering-queued-selection",
767+
true,
768+
);
769+
yield* Effect.gen(function* () {
770+
const orchestrator = yield* Orchestrator.OrchestratorV2;
771+
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
772+
const threadId = yield* startFirstTurn;
773+
const queuedSelection = {
774+
...runSelection,
775+
options: [{ id: "effort", value: "medium" }],
776+
};
777+
yield* orchestrator.dispatch({
778+
type: "message.dispatch",
779+
commandId: CommandId.make("queued"),
780+
threadId,
781+
messageId: MessageId.make("message:queued"),
782+
text: "queued with medium effort",
783+
attachments: [],
784+
modelSelection: queuedSelection,
785+
dispatchMode: { type: "queue_after_active" },
786+
createdBy: "user",
787+
creationSource: "web",
788+
});
789+
const before = yield* orchestrator.getThreadProjection(threadId);
790+
const queued = before.runs.find((run) => run.status === "queued")!;
791+
assert.deepEqual(queued.modelSelection, queuedSelection);
792+
assert.deepEqual(before.thread.modelSelection, runSelection);
793+
794+
yield* orchestrator.dispatch({
795+
type: "queued-message.promote-to-steer",
796+
commandId: CommandId.make("promote"),
797+
threadId,
798+
queuedRunId: queued.id,
799+
targetRunId: started[0]!.runId,
800+
});
801+
yield* worker.drain();
802+
803+
const after = yield* orchestrator.getThreadProjection(threadId);
804+
assert.deepEqual(steered, ["queued with medium effort"]);
805+
assert.lengthOf(started, 1);
806+
assert.deepEqual(after.thread.modelSelection, queuedSelection);
807+
assert.deepEqual(after.runs[0]?.modelSelection, runSelection);
808+
assert.equal(after.runs.find((run) => run.id === queued.id)?.status, "cancelled");
809+
}).pipe(Effect.provide(layer));
810+
}),
811+
),
812+
);
813+
762814
it.effect("starts a steer that missed the turn on the saved next-turn selection", () =>
763815
Effect.scoped(
764816
Effect.gen(function* () {

0 commit comments

Comments
 (0)