Skip to content

Commit 21d76f8

Browse files
fix(server): ACP threads accept a model change after their session detaches
Settling a thread detaches its provider session and drops the session record, so the switch planner fell back to the ACP adapter's base capabilities and refused the change. With no session record there is nothing to switch in place, so the selection now applies when the next session starts. Fixes #35938 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 281e97c commit 21d76f8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ export const layer: Layer.Layer<
104104
Option.isSome(targetAdapter) &&
105105
Option.isSome(currentInstance) &&
106106
(currentSession !== undefined || currentProviderThread !== undefined)
107-
? yield* targetAdapter.value.planSelectionTransition({
108-
current,
109-
target: targetModelSelection,
110-
sessionCapabilities: negotiatedCapabilities ?? currentInstance.value.capabilities,
111-
})
107+
? negotiatedCapabilities === undefined
108+
? // No session record left to switch in place; the next session starts with it.
109+
({ type: "apply_on_next_turn" } as const)
110+
: yield* targetAdapter.value.planSelectionTransition({
111+
current,
112+
target: targetModelSelection,
113+
sessionCapabilities: negotiatedCapabilities,
114+
})
112115
: undefined;
113116
const transition =
114117
Option.isNone(targetInstance) || Option.isNone(targetAdapter)

0 commit comments

Comments
 (0)