@@ -6361,6 +6361,120 @@ describe("ClaudeAdapterV2 background wake turns", () => {
63616361 ),
63626362 );
63636363
6364+ // regression: #34549 a model change sent with a steer was shown but never applied to the turn.
6365+ it.effect("applies a model change sent with a steer to the running turn", () =>
6366+ Effect.scoped(
6367+ Effect.gen(function* () {
6368+ const harness = yield* makeWakeHarness;
6369+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
6370+ const opus = {
6371+ instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
6372+ model: "claude-opus-5-5",
6373+ } satisfies ModelSelection;
6374+ const input = makeClaudeTestTurnInput({
6375+ threadId: harness.threadId,
6376+ providerThread: harness.providerThread,
6377+ now: yield* DateTime.now,
6378+ attemptId: RunAttemptId.make("attempt-steer-model-change"),
6379+ text: "Run the slow build.",
6380+ attachments: [],
6381+ modelSelection: opus,
6382+ });
6383+ yield* harness.runtime.startTurn(input);
6384+ yield* harness.runtime.steerTurn({
6385+ threadId: harness.threadId,
6386+ runId: input.runId,
6387+ providerThread: harness.providerThread,
6388+ providerTurnId: idAllocator.derive.providerTurn({
6389+ driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
6390+ nativeTurnId: `turn:${input.attemptId}`,
6391+ }),
6392+ modelSelection: { ...opus, model: "claude-sonnet-4-6" },
6393+ message: {
6394+ createdBy: "user",
6395+ creationSource: "web",
6396+ messageId: MessageId.make("steer-model-change"),
6397+ text: "Which model are you?",
6398+ attachments: [],
6399+ },
6400+ });
6401+ assert.deepEqual(harness.liveSelectionChanges, [
6402+ { model: "claude-sonnet-4-6" },
6403+ { effortLevel: "high", fastMode: null, ultracode: null },
6404+ ]);
6405+ assert.lengthOf(harness.offeredMessages, 2);
6406+ }).pipe(
6407+ Effect.provide(
6408+ Layer.mergeAll(
6409+ IdAllocator.layer,
6410+ McpProviderSessions.layer,
6411+ NodeServices.layer,
6412+ NodeCrypto.layer,
6413+ ),
6414+ ),
6415+ ),
6416+ ),
6417+ );
6418+
6419+ it.effect("fails a model-changing steer when the turn ends during the selection change", () =>
6420+ Effect.scoped(
6421+ Effect.gen(function* () {
6422+ let duringFlags: Effect.Effect<void> = Effect.void;
6423+ const harness = yield* makeWakeHarnessWithOptions({
6424+ applyFlagSettings: () => Effect.suspend(() => duringFlags),
6425+ });
6426+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
6427+ const opus = {
6428+ instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
6429+ model: "claude-opus-5-5",
6430+ } satisfies ModelSelection;
6431+ const input = makeClaudeTestTurnInput({
6432+ threadId: harness.threadId,
6433+ providerThread: harness.providerThread,
6434+ now: yield* DateTime.now,
6435+ attemptId: RunAttemptId.make("attempt-steer-model-change-race"),
6436+ text: "Run the slow build.",
6437+ attachments: [],
6438+ modelSelection: opus,
6439+ });
6440+ yield* harness.runtime.startTurn(input);
6441+ duringFlags = harness
6442+ .offerAndWait(turnOneResult)
6443+ .pipe(Effect.andThen(Queue.take(harness.terminalReceipts)), Effect.asVoid);
6444+ const steer = yield* harness.runtime
6445+ .steerTurn({
6446+ threadId: harness.threadId,
6447+ runId: input.runId,
6448+ providerThread: harness.providerThread,
6449+ providerTurnId: idAllocator.derive.providerTurn({
6450+ driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
6451+ nativeTurnId: `turn:${input.attemptId}`,
6452+ }),
6453+ modelSelection: { ...opus, model: "claude-sonnet-4-6" },
6454+ message: {
6455+ createdBy: "user",
6456+ creationSource: "web",
6457+ messageId: MessageId.make("steer-model-change-race"),
6458+ text: "Which model are you?",
6459+ attachments: [],
6460+ },
6461+ })
6462+ .pipe(Effect.result);
6463+ assert.equal(steer._tag, "Failure");
6464+ assert.lengthOf(harness.offeredMessages, 1);
6465+ }).pipe(
6466+ Effect.provide(
6467+ Layer.mergeAll(
6468+ IdAllocator.layer,
6469+ McpProviderSessions.layer,
6470+ NodeServices.layer,
6471+ NodeCrypto.layer,
6472+ ),
6473+ ),
6474+ ),
6475+ ),
6476+ );
6477+
63646478 it.effect("re-sends the model on the turn after a live selection change fails", () =>
63656479 Effect.scoped(
63666480 Effect.gen(function* () {
0 commit comments