Skip to content

Commit 44d1758

Browse files
t3dotggclaude
andcommitted
fix(server): load user messages when promoting a queued message to a restart
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c518596 commit 44d1758

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9362,7 +9362,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
93629362
"runtimeRequests",
93639363
"subagents",
93649364
],
9365-
{ turnItemTypes: [], messageRoles: ["user"] },
9365+
// User messages measure a restart's model switch.
9366+
{ turnItemTypes: ["user_message"], messageRoles: ["user"] },
93669367
);
93679368
if (projection.thread.archivedAt !== null || projection.thread.deletedAt !== null) {
93689369
return yield* new OrchestratorDispatchError({

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,55 @@ it.effect("steers a promoted queued message with the selection it was queued wit
11751175
),
11761176
);
11771177

1178+
it.effect("marks the model switch on a promoted message that restarts the turn", () =>
1179+
Effect.scoped(
1180+
Effect.gen(function* () {
1181+
const { started, layer, startFirstTurn } = yield* nextTurnSelectionHarness(
1182+
"promote-restart-switch",
1183+
true,
1184+
false,
1185+
);
1186+
const otherSelection = { ...runSelection, model: "other-model" };
1187+
yield* Effect.gen(function* () {
1188+
const orchestrator = yield* Orchestrator.OrchestratorV2;
1189+
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
1190+
const threadId = yield* startFirstTurn;
1191+
yield* orchestrator.dispatch({
1192+
type: "message.dispatch",
1193+
commandId: CommandId.make("queued"),
1194+
threadId,
1195+
messageId: MessageId.make("message:queued"),
1196+
text: "queued",
1197+
attachments: [],
1198+
modelSelection: otherSelection,
1199+
dispatchMode: { type: "queue_after_active" },
1200+
createdBy: "user",
1201+
creationSource: "web",
1202+
});
1203+
const queuedRun = (yield* orchestrator.getThreadProjection(threadId)).runs.find(
1204+
(run) => run.status === "queued",
1205+
)!;
1206+
yield* orchestrator.dispatch({
1207+
type: "queued-message.promote-to-steer",
1208+
commandId: CommandId.make("promote"),
1209+
threadId,
1210+
queuedRunId: queuedRun.id,
1211+
targetRunId: started[0]!.runId,
1212+
});
1213+
yield* worker.drain();
1214+
1215+
const promoted = (yield* orchestrator.getThreadProjection(threadId)).turnItems.find(
1216+
(item) => item.type === "user_message" && item.messageId === "message:queued",
1217+
);
1218+
assert.deepEqual(promoted?.type === "user_message" ? promoted.modelSwitch : undefined, {
1219+
from: runSelection,
1220+
to: otherSelection,
1221+
});
1222+
}).pipe(Effect.provide(layer));
1223+
}),
1224+
),
1225+
);
1226+
11781227
it.effect("keeps a queued message queued when promoted into a run that Stop reached", () =>
11791228
Effect.scoped(
11801229
Effect.gen(function* () {

0 commit comments

Comments
 (0)