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

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

fix(acp): new Copilot threads run the model the composer shows (#35199)

Julius Marminge committed Nov 12, 2026 at 05:16 UTC e9e934bb3db7b13c8d09f103a59f317935e0bd72
4 files changed +154 -13
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
+85 -1
@@ -23,6 +23,7 @@ import * as Stream from "effect/Stream";
23 import * as Effect from "effect/Effect";
24 import * as FileSystem from "effect/FileSystem";
25 import * as Layer from "effect/Layer";
26 +import * as Option from "effect/Option";
27 import * as Path from "effect/Path";
28 import * as Schema from "effect/Schema";
29 import * as HttpClient from "effect/http/HttpClient";
@@ -471,6 +472,7 @@ describe("AcpRegistryAdapterV2", () => {
472 const openWithStoredPicks = Effect.fn("openWithStoredPicks")(function* (input: {
473 readonly setup: unknown;
474 readonly pickFrames: ReadonlyArray<Frame>;
475 + readonly agentId?: string;
476 readonly customModels?: ReadonlyArray<string>;
477 readonly storedModel?: string;
478 readonly storedModePick?: string;
@@ -478,6 +480,7 @@ describe("AcpRegistryAdapterV2", () => {
480 readonly rejectedModel?: string;
481 readonly storedOptions?: ReadonlyArray<{ readonly id: string; readonly value: string }>;
482 readonly failsConfiguration?: boolean;
483 + readonly liveConfiguration?: AcpRegistryLiveConfiguration;
484 }) {
485 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
486 // Scope release gives the replay agent at most a second to exit, so the status
@@ -524,7 +527,7 @@ describe("AcpRegistryAdapterV2", () => {
527 selfInvocation: yield* resolveSelfInvocation(),
528 instanceId,
529 settings: yield* decodeAcpRegistryAdapterSettings({
527 - agentId: "fixture-agent",
530 + agentId: input.agentId ?? "fixture-agent",
531 authMethodId: "test",
532 customModels: input.customModels ?? [],
533 }),
@@ -545,6 +548,8 @@ describe("AcpRegistryAdapterV2", () => {
548 layerInjectedRuntimeCatalog,
549 Layer.mock(AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator)({
550 withForegroundStartup: (_startupKey, effect) => effect,
551 + getLiveConfiguration: () =>
552 + Effect.sync(() => Option.fromUndefinedOr(published ?? input.liveConfiguration)),
553 publishLiveConfiguration: (_instanceId, configuration) =>
554 Effect.sync(() => {
555 published = configuration;
@@ -799,6 +804,85 @@ describe("AcpRegistryAdapterV2", () => {
804 }).pipe(Effect.provide(layerTest), Effect.scoped),
805 );
806
807 + // Copilot's session/new reports its built-in default, not the model it will run
808 + // (github/copilot-cli#5363), so the selected model must be written even when it matches,
809 + // and an unset effort gets the value the composer shows.
810 + it.effect(
811 + "writes the selected Copilot model and the shown effort when session/new reports defaults",
812 + () => {
813 + const copilotModel = (currentValue: string) => ({
814 + ...modelOption("model", currentValue),
815 + options: ["claude-sonnet-5.5", "claude-haiku-4.5"].map((value) => ({
816 + value,
817 + name: value,
818 + })),
819 + });
820 + const effort = (currentValue: string) => ({
821 + id: "reasoning_effort",
822 + name: "Reasoning effort",
823 + category: "thought_level",
824 + type: "select",
825 + currentValue,
826 + options: ["medium", "xhigh"].map((value) => ({ value, name: value })),
827 + });
828 + return openWithStoredPicks({
829 + agentId: "github-copilot-cli",
830 + setup: { configOptions: [copilotModel("claude-sonnet-5.5"), effort("medium")] },
831 + storedModel: "claude-sonnet-5.5",
832 + liveConfiguration: {
833 + models: [],
834 + currentModelId: null,
835 + configOptions: [
836 + {
837 + id: "reasoning_effort",
838 + label: "Reasoning effort",
839 + type: "select",
840 + role: "reasoning",
841 + currentValue: "xhigh",
842 + options: [
843 + { id: "medium", label: "medium" },
844 + { id: "xhigh", label: "xhigh" },
845 + ],
846 + },
847 + ],
848 + },
849 + pickFrames: [
850 + // The new session's own update replaces the shared live configuration.
851 + {
852 + type: "emit_inbound",
853 + frame: {
854 + kind: "notification",
855 + method: "session/update",
856 + params: {
857 + sessionId: "agent-session",
858 + update: {
859 + sessionUpdate: "config_option_update",
860 + configOptions: [copilotModel("claude-sonnet-5.5"), effort("medium")],
861 + },
862 + },
863 + },
864 + },
865 + outbound("session/set_config_option", {
866 + sessionId: "agent-session",
867 + configId: "model",
868 + value: "claude-sonnet-5.5",
869 + }),
870 + answer("session/set_config_option", {
871 + configOptions: [copilotModel("claude-sonnet-5.5"), effort("medium")],
872 + }),
873 + outbound("session/set_config_option", {
874 + sessionId: "agent-session",
875 + configId: "reasoning_effort",
876 + value: "xhigh",
877 + }),
878 + answer("session/set_config_option", {
879 + configOptions: [copilotModel("claude-sonnet-5.5"), effort("xhigh")],
880 + }),
881 + ],
882 + }).pipe(Effect.provide(layerTest), Effect.scoped);
883 + },
884 + );
885 +
886 it.effect.each([
887 "config",
888 "legacy",
packages/provider-acp-registry/src/server/adapter.ts
+24
@@ -258,6 +258,8 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
258 normalizeSessionUpdate: copilotRouting.normalizeSessionUpdate,
259 extractSubagentUpdate: extractCopilotSubagentUpdate,
260 restartRuntimeAfterPromptError: isCopilotLostSessionError,
261 + // session/new reports a built-in default, not the model Copilot runs (github/copilot-cli#5363).
262 + alwaysSetModel: true,
263 }),
264 makeRuntime: options.makeRuntime ?? makeAcpRegistryRuntime(runtimeOptions, catalog),
265 ...(runtimeCoordinator === undefined
@@ -268,6 +270,28 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
270 options.instanceId,
271 normalizeAcpRegistryCommands(commands),
272 ),
273 + // A new Copilot session starts at its own effort, not the one the composer shows.
274 + ...(isCopilot
275 + ? {
276 + unsetOptionDefaults: runtimeCoordinator
277 + .getLiveConfiguration(options.instanceId)
278 + .pipe(
279 + Effect.map(
280 + Option.match({
281 + onNone: () => [],
282 + onSome: ({ configOptions }) =>
283 + configOptions.flatMap((descriptor) =>
284 + descriptor.type === "select" &&
285 + descriptor.role === "reasoning" &&
286 + descriptor.currentValue !== undefined
287 + ? [{ id: descriptor.id, value: descriptor.currentValue }]
288 + : [],
289 + ),
290 + }),
291 + ),
292 + ),
293 + }
294 + : {}),
295 onSessionConfigurationUpdate: (configOptions, modeState, modelState) =>
296 runtimeCoordinator.publishLiveConfiguration(
297 options.instanceId,
packages/provider-acp/src/server/AcpSessionRuntime.ts
+14 -3
@@ -1186,7 +1186,11 @@ export class AcpSessionRuntime extends Context.Service<
1186 readonly setConfigOption: (
1187 configId: string,
1188 value: string | boolean,
1189 - options?: { readonly allowUnlistedValue?: boolean },
1189 + options?: {
1190 + readonly allowUnlistedValue?: boolean;
1191 + /** Sends the write even when the cached value already matches it. */
1192 + readonly resendCurrentValue?: boolean;
1193 + },
1194 ) => Effect.Effect<EffectAcpSchema.SetSessionConfigOptionResponse, EffectAcpErrors.AcpError>;
1195 readonly setModel: (model: string) => Effect.Effect<void, EffectAcpErrors.AcpError>;
1196 readonly request: (
@@ -2031,7 +2035,10 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
2035 const setConfigOption = (
2036 configId: string,
2037 value: string | boolean,
2034 - options?: { readonly allowUnlistedValue?: boolean },
2038 + options?: {
2039 + readonly allowUnlistedValue?: boolean;
2040 + readonly resendCurrentValue?: boolean;
2041 + },
2042 ): Effect.Effect<EffectAcpSchema.SetSessionConfigOptionResponse, EffectAcpErrors.AcpError> =>
2043 validateConfigOptionValue(configId, value, options?.allowUnlistedValue === true).pipe(
2044 Effect.andThen(getStartedState),
@@ -2039,7 +2046,11 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
2046 SubscriptionRef.get(configOptionsRef).pipe(
2047 Effect.flatMap((configOptions) => {
2048 const existing = findSessionConfigOption(configOptions, configId);
2042 - if (existing && configOptionCurrentValueMatches(existing, value)) {
2049 + if (
2050 + existing &&
2051 + options?.resendCurrentValue !== true &&
2052 + configOptionCurrentValueMatches(existing, value)
2053 + ) {
2054 return Effect.succeed({
2055 configOptions,
2056 } satisfies EffectAcpSchema.SetSessionConfigOptionResponse);
packages/provider-acp/src/server/adapter.ts
+31 -9
@@ -374,6 +374,10 @@ export interface AcpAdapterV2Flavor {
374 ChildProcessSpawner.ChildProcessSpawner | SecureRandom.SecureRandom | Scope.Scope
375 >;
376 readonly customModels?: ReadonlyArray<string>;
377 + /** The agent may run another model than session/new reports, so the model is always written. */
378 + readonly alwaysSetModel?: boolean;
379 + /** Values the client shows for options a new session's selection leaves unset. */
380 + readonly unsetOptionDefaults?: Effect.Effect<NonNullable<ModelSelection["options"]>>;
381 readonly resolveModelId?: (selection: ModelSelection) => string | undefined;
382 /**
383 * The agent advertises its model option only after `session/new` returns
@@ -7155,6 +7159,8 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
7159 },
7160 );
7161
7162 + // Read before the session exists: its own config updates replace what the client showed.
7163 + const unsetOptionDefaults = yield* flavor.unsetOptionDefaults ?? Effect.succeed([]);
7164 const initialStart = yield* Effect.result(
7165 startAcpRuntime(input.threadId, input.initialNativeThreadId),
7166 );
@@ -7253,6 +7259,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
7259 startResult: AcpSessionRuntime.AcpSessionRuntimeStartResult,
7260 modelSelection: ModelSelection,
7261 runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy,
7262 + unsetOptionDefaults: NonNullable<ModelSelection["options"]> = [],
7263 ) {
7264 yield* Ref.set(activeSelection, null);
7265 yield* validateModelSelection(modelSelection);
@@ -7288,7 +7295,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
7295 )
7296 ) {
7297 yield* runtime
7291 - .setConfigOption(modelOption.id, requestedModel)
7298 + .setConfigOption(modelOption.id, requestedModel, {
7299 + resendCurrentValue: flavor.alwaysSetModel === true,
7300 + })
7301 .pipe(Effect.mapError(rejectedModel));
7302 appliedModel = requestedModel;
7303 }
@@ -7343,13 +7352,21 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
7352 : undefined;
7353 return granted !== undefined && !isRuntimeModeAbove(granted, ceiling);
7354 };
7346 - const optionSelections = (modelSelection.options ?? []).flatMap((selection) => {
7347 - if (flavor.ownedModelOptionIds?.includes(selection.id) === true) return [];
7348 - if (!withinCeiling(selection)) return [];
7349 - return [
7350 - selection.value === ACP_EMPTY_OPTION_VALUE ? { ...selection, value: "" } : selection,
7351 - ];
7352 - });
7355 + const explicitSelections = modelSelection.options ?? [];
7356 + const implicitSelections = unsetOptionDefaults.filter(
7357 + (implicit) => !explicitSelections.some((selection) => selection.id === implicit.id),
7358 + );
7359 + const optionSelections = [...explicitSelections, ...implicitSelections].flatMap(
7360 + (selection) => {
7361 + if (flavor.ownedModelOptionIds?.includes(selection.id) === true) return [];
7362 + if (!withinCeiling(selection)) return [];
7363 + return [
7364 + selection.value === ACP_EMPTY_OPTION_VALUE
7365 + ? { ...selection, value: "" }
7366 + : selection,
7367 + ];
7368 + },
7369 + );
7370 const availableConfigIds = new Set(configOptions.map((option) => option.id));
7371 const hasNativeConfigWithSyntheticModeId = availableConfigIds.has(
7372 ACP_SESSION_MODE_OPTION_ID,
@@ -7501,7 +7518,12 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
7518 );
7519 });
7520
7504 - yield* configureSession(started, input.modelSelection, input.runtimePolicy);
7521 + yield* configureSession(
7522 + started,
7523 + input.modelSelection,
7524 + input.runtimePolicy,
7525 + started.sessionId !== input.initialNativeThreadId ? unsetOptionDefaults : [],
7526 + );
7527 yield* Ref.set(activeSelection, input.modelSelection);
7528 yield* Ref.set(activeInteractionMode, input.runtimePolicy.interactionMode);
7529 const createdAt = yield* DateTime.now;