@devries-cameron20 / t3code-1 / commits / ec9d994f00
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): changing Claude effort no longer re-sends the model (#22272)

Co-authored-by: maria-rcks <maria@kuuro.net>

F4llen committed Oct 31, 2026 at 04:41 UTC ec9d994f002f7615bacfa167bb2b7a62dbc94b4a
2 files changed +70 -4
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+63 -3
@@ -2867,6 +2867,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
2867 readonly close?: (sdkMessages: Queue.Queue<SDKMessage>) => Effect.Effect<void>;
2868 readonly interrupt?: Effect.Effect<void>;
2869 readonly setPermissionMode?: ClaudeAdapterV2.ClaudeAgentSdkQuerySession["setPermissionMode"];
2870 + readonly applyFlagSettings?: ClaudeAdapterV2.ClaudeAgentSdkQuerySession["applyFlagSettings"];
2871 readonly stopTask?: (
2872 taskId: string,
2873 ) => Effect.Effect<void, ClaudeAdapterV2.ClaudeAgentSdkQueryRunnerError>;
@@ -3014,7 +3015,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
3015 applyFlagSettings: (settings) =>
3016 Effect.sync(() => {
3017 liveSelectionChanges.push(settings);
3017 - }),
3018 + }).pipe(
3019 + Effect.andThen(() => options?.applyFlagSettings?.(settings) ?? Effect.void),
3020 + ),
3021 setPermissionMode: (mode) =>
3022 Effect.sync(() => {
3023 permissionModeChanges.push(mode);
@@ -4878,7 +4881,6 @@ describe("ClaudeAdapterV2 background wake turns", () => {
4881 yield* harness.runtime.startTurn(turn(4, { ...normal, model: "claude-sonnet-4-6" }));
4882 yield* settle;
4883 assert.deepEqual(harness.liveSelectionChanges, [
4881 - { model: "claude-opus-5-5" },
4884 { effortLevel: "xhigh", fastMode: true, ultracode: true },
4885 { model: "claude-sonnet-4-6" },
4886 { effortLevel: "high", fastMode: null, ultracode: null },
@@ -4903,7 +4905,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
4905 }
4906 assert.strictEqual(harness.getOpenedOptions(), originalOptions);
4907 assert.lengthOf(harness.offeredMessages, 4);
4906 - assert.lengthOf(harness.liveSelectionChanges, 4);
4908 + assert.lengthOf(harness.liveSelectionChanges, 3);
4909 assert.isTrue(yield* harness.hasPendingBackgroundWork);
4910 }).pipe(
4911 Effect.provide(
@@ -4913,6 +4915,64 @@ describe("ClaudeAdapterV2 background wake turns", () => {
4915 ),
4916 );
4917
4918 + it.effect("re-sends the model on the turn after a live selection change fails", () =>
4919 + Effect.scoped(
4920 + Effect.gen(function* () {
4921 + let failFlags = true;
4922 + const harness = yield* makeWakeHarnessWithOptions({
4923 + applyFlagSettings: () =>
4924 + Effect.suspend(() => {
4925 + if (!failFlags) return Effect.void;
4926 + failFlags = false;
4927 + return Effect.fail(
4928 + new ClaudeAdapterV2.ClaudeAgentSdkQueryRunnerError({
4929 + method: "applyFlagSettings",
4930 + cause: new Error("control request failed"),
4931 + }),
4932 + );
4933 + }),
4934 + });
4935 + const now = yield* DateTime.now;
4936 + const opus = {
4937 + instanceId: ClaudeAdapterV2.CLAUDE_DEFAULT_INSTANCE_ID,
4938 + model: "claude-opus-5-5",
4939 + } satisfies ModelSelection;
4940 + const turn = (ordinal: number, modelSelection: ModelSelection) =>
4941 + makeClaudeTestTurnInput({
4942 + threadId: harness.threadId,
4943 + providerThread: harness.providerThread,
4944 + now,
4945 + attemptId: RunAttemptId.make(`attempt-failed-live-change:${ordinal}`),
4946 + text: `Request ${ordinal}`,
4947 + attachments: [],
4948 + providerTurnOrdinal: ordinal,
4949 + modelSelection,
4950 + });
4951 + yield* harness.runtime.startTurn(turn(1, opus));
4952 + yield* harness.offerAndWait(turnOneResult);
4953 + yield* Queue.take(harness.terminalReceipts);
4954 +
4955 + const failed = yield* harness.runtime
4956 + .startTurn(turn(2, { ...opus, model: "claude-sonnet-4-6" }))
4957 + .pipe(Effect.result);
4958 + assert.equal(failed._tag, "Failure");
4959 +
4960 + // The process may now run Sonnet, so returning to Opus must send it.
4961 + yield* harness.runtime.startTurn(turn(3, opus));
4962 + assert.deepEqual(harness.liveSelectionChanges, [
4963 + { model: "claude-sonnet-4-6" },
4964 + { effortLevel: "high", fastMode: null, ultracode: null },
4965 + { model: "claude-opus-5-5" },
4966 + { effortLevel: "medium", fastMode: false, ultracode: null },
4967 + ]);
4968 + }).pipe(
4969 + Effect.provide(
4970 + Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
4971 + ),
4972 + ),
4973 + ),
4974 + );
4975 +
4976 it.effect.each(["completed", "interrupted"] as const)(
4977 "projects Claude thinking blocks when %s",
4978 (status) =>
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+7 -1
@@ -10121,7 +10121,13 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
10121 existing.openedPermissionMode === queryPolicy.permissionMode)
10122 ) {
10123 const live = existing;
10124 - yield* live.query.setModel(compiledSelection.apiModelId).pipe(
10124 + // Preserve launcher-selected models unless the model changed or a failed update left it unknown.
10125 + yield* (
10126 + live.selection.queryIdentity === "" ||
10127 + live.selection.apiModelId !== compiledSelection.apiModelId
10128 + ? live.query.setModel(compiledSelection.apiModelId)
10129 + : Effect.void
10130 + ).pipe(
10131 Effect.andThen(
10132 live.query.applyFlagSettings(claudeLiveSelectionFlagSettings(compiledSelection)),
10133 ),