Skip to content

Commit 8a08403

Browse files
fix(acp): new Copilot threads run the effort the composer shows
A new thread with no effort pick shows the effort Copilot last reported for the provider instance, but dispatch leaves it out and Copilot starts the new session at its own effort. When T3 creates a new Copilot session, it now writes the shown effort for any reasoning option the thread left unset. Refs #35172 AI-assisted; verified with the tests and tools listed above.
1 parent f500539 commit 8a08403

3 files changed

Lines changed: 92 additions & 12 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts‎

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import * as Stream from "effect/Stream";
2323
import * as Effect from "effect/Effect";
2424
import * as FileSystem from "effect/FileSystem";
2525
import * as Layer from "effect/Layer";
26+
import * as Option from "effect/Option";
2627
import * as Path from "effect/Path";
2728
import * as Schema from "effect/Schema";
2829
import * as HttpClient from "effect/http/HttpClient";
@@ -479,6 +480,7 @@ describe("AcpRegistryAdapterV2", () => {
479480
readonly rejectedModel?: string;
480481
readonly storedOptions?: ReadonlyArray<{ readonly id: string; readonly value: string }>;
481482
readonly failsConfiguration?: boolean;
483+
readonly liveConfiguration?: AcpRegistryLiveConfiguration;
482484
}) {
483485
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
484486
// Scope release gives the replay agent at most a second to exit, so the status
@@ -546,6 +548,8 @@ describe("AcpRegistryAdapterV2", () => {
546548
layerInjectedRuntimeCatalog,
547549
Layer.mock(AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator)({
548550
withForegroundStartup: (_startupKey, effect) => effect,
551+
getLiveConfiguration: () =>
552+
Effect.succeed(Option.fromUndefinedOr(input.liveConfiguration)),
549553
publishLiveConfiguration: (_instanceId, configuration) =>
550554
Effect.sync(() => {
551555
published = configuration;
@@ -801,9 +805,10 @@ describe("AcpRegistryAdapterV2", () => {
801805
);
802806

803807
// Copilot's session/new reports its built-in default, not the model it will run
804-
// (github/copilot-cli#5363), so the selected model must be written even when it matches.
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.
805810
it.effect(
806-
"writes the selected Copilot model even when session/new reports it as current",
811+
"writes the selected Copilot model and the shown effort when session/new reports defaults",
807812
() => {
808813
const copilotModel = (currentValue: string) => ({
809814
...modelOption("model", currentValue),
@@ -812,18 +817,51 @@ describe("AcpRegistryAdapterV2", () => {
812817
name: value,
813818
})),
814819
});
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+
});
815828
return openWithStoredPicks({
816829
agentId: "github-copilot-cli",
817-
setup: { configOptions: [copilotModel("claude-sonnet-5.5")] },
830+
setup: { configOptions: [copilotModel("claude-sonnet-5.5"), effort("medium")] },
818831
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+
},
819849
pickFrames: [
820850
outbound("session/set_config_option", {
821851
sessionId: "agent-session",
822852
configId: "model",
823853
value: "claude-sonnet-5.5",
824854
}),
825855
answer("session/set_config_option", {
826-
configOptions: [copilotModel("claude-sonnet-5.5")],
856+
configOptions: [copilotModel("claude-sonnet-5.5"), effort("medium")],
857+
}),
858+
outbound("session/set_config_option", {
859+
sessionId: "agent-session",
860+
configId: "reasoning_effort",
861+
value: "xhigh",
862+
}),
863+
answer("session/set_config_option", {
864+
configOptions: [copilotModel("claude-sonnet-5.5"), effort("xhigh")],
827865
}),
828866
],
829867
}).pipe(Effect.provide(layerTest), Effect.scoped);

‎packages/provider-acp-registry/src/server/adapter.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,28 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
270270
options.instanceId,
271271
normalizeAcpRegistryCommands(commands),
272272
),
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+
: {}),
273295
onSessionConfigurationUpdate: (configOptions, modeState, modelState) =>
274296
runtimeCoordinator.publishLiveConfiguration(
275297
options.instanceId,

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ export interface AcpAdapterV2Flavor {
376376
readonly customModels?: ReadonlyArray<string>;
377377
/** The agent may run another model than session/new reports, so the model is always written. */
378378
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"]>>;
379381
readonly resolveModelId?: (selection: ModelSelection) => string | undefined;
380382
/**
381383
* The agent advertises its model option only after `session/new` returns
@@ -7255,6 +7257,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
72557257
startResult: AcpSessionRuntime.AcpSessionRuntimeStartResult,
72567258
modelSelection: ModelSelection,
72577259
runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy,
7260+
newSession = false,
72587261
) {
72597262
yield* Ref.set(activeSelection, null);
72607263
yield* validateModelSelection(modelSelection);
@@ -7347,13 +7350,25 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
73477350
: undefined;
73487351
return granted !== undefined && !isRuntimeModeAbove(granted, ceiling);
73497352
};
7350-
const optionSelections = (modelSelection.options ?? []).flatMap((selection) => {
7351-
if (flavor.ownedModelOptionIds?.includes(selection.id) === true) return [];
7352-
if (!withinCeiling(selection)) return [];
7353-
return [
7354-
selection.value === ACP_EMPTY_OPTION_VALUE ? { ...selection, value: "" } : selection,
7355-
];
7356-
});
7353+
const explicitSelections = modelSelection.options ?? [];
7354+
const implicitSelections =
7355+
newSession && flavor.unsetOptionDefaults !== undefined
7356+
? (yield* flavor.unsetOptionDefaults).filter(
7357+
(implicit) =>
7358+
!explicitSelections.some((selection) => selection.id === implicit.id),
7359+
)
7360+
: [];
7361+
const optionSelections = [...explicitSelections, ...implicitSelections].flatMap(
7362+
(selection) => {
7363+
if (flavor.ownedModelOptionIds?.includes(selection.id) === true) return [];
7364+
if (!withinCeiling(selection)) return [];
7365+
return [
7366+
selection.value === ACP_EMPTY_OPTION_VALUE
7367+
? { ...selection, value: "" }
7368+
: selection,
7369+
];
7370+
},
7371+
);
73577372
const availableConfigIds = new Set(configOptions.map((option) => option.id));
73587373
const hasNativeConfigWithSyntheticModeId = availableConfigIds.has(
73597374
ACP_SESSION_MODE_OPTION_ID,
@@ -7505,7 +7520,12 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
75057520
);
75067521
});
75077522

7508-
yield* configureSession(started, input.modelSelection, input.runtimePolicy);
7523+
yield* configureSession(
7524+
started,
7525+
input.modelSelection,
7526+
input.runtimePolicy,
7527+
started.sessionId !== input.initialNativeThreadId,
7528+
);
75097529
yield* Ref.set(activeSelection, input.modelSelection);
75107530
yield* Ref.set(activeInteractionMode, input.runtimePolicy.interactionMode);
75117531
const createdAt = yield* DateTime.now;

0 commit comments

Comments
 (0)