Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/server/src/orchestration-v2/EffectWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ export const executorLayer: Layer.Layer<
text: message.text,
...(message.context ? { context: message.context } : {}),
attachments: message.attachments,
modelSelection: run.modelSelection,
// A user's follow-up starts on the thread's saved selection,
// which already holds the steer's choice. A delegated
// completion stays pinned to the run it reports to.
...(message.delegatedCompletion === undefined
? {}
: { modelSelection: run.modelSelection }),
dispatchMode: {
type:
message.delegatedCompletion === undefined
Expand Down
14 changes: 11 additions & 3 deletions apps/server/src/orchestration-v2/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3631,17 +3631,25 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
);

if (steeringPolicy === "active_steering") {
// The steer's selection becomes the saved next-turn choice, even when it
// matches the running run again. A delegated completion carries the
// run's selection, not a user choice, so it never replaces the saved one.
// The saved choice may name another instance, so it moves with the steer.
const instanceChanged =
input.projection.thread.providerInstanceId !== input.modelSelection.instanceId;
if (
selectionChanged &&
!modelSelectionsEqual(input.projection.thread.modelSelection, input.modelSelection)
input.delegatedCompletion === undefined &&
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
(instanceChanged ||
!modelSelectionsEqual(input.projection.thread.modelSelection, input.modelSelection))
) {
yield* emitEvent({
type: "thread.model-selection-updated",
type: instanceChanged ? "thread.provider-switched" : "thread.model-selection-updated",
threadId: input.command.threadId,
providerInstanceId: input.modelSelection.instanceId,
occurredAt: now,
payload: {
...input.projection.thread,
providerInstanceId: input.modelSelection.instanceId,
modelSelection: input.modelSelection,
updatedAt: now,
},
Expand Down
Loading
Loading