Skip to content

Commit d0cdbc5

Browse files
fix(acp): read Copilot's shown effort before the new session can replace it
Copilot answers the model write with a config_option_update carrying the new session's own effort, and T3 publishes that as the instance's live configuration. Reading the shown effort after the model write therefore saw the new session's value and sent no effort write. The adapter now reads it before starting the session. Refs #35172 AI-assisted; verified with the tests and tools listed above.
1 parent 8a08403 commit d0cdbc5

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ describe("AcpRegistryAdapterV2", () => {
549549
Layer.mock(AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator)({
550550
withForegroundStartup: (_startupKey, effect) => effect,
551551
getLiveConfiguration: () =>
552-
Effect.succeed(Option.fromUndefinedOr(input.liveConfiguration)),
552+
Effect.sync(() => Option.fromUndefinedOr(published ?? input.liveConfiguration)),
553553
publishLiveConfiguration: (_instanceId, configuration) =>
554554
Effect.sync(() => {
555555
published = configuration;
@@ -847,6 +847,21 @@ describe("AcpRegistryAdapterV2", () => {
847847
],
848848
},
849849
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+
},
850865
outbound("session/set_config_option", {
851866
sessionId: "agent-session",
852867
configId: "model",

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7159,6 +7159,8 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
71597159
},
71607160
);
71617161

7162+
// Read before the session exists: its own config updates replace what the client showed.
7163+
const unsetOptionDefaults = yield* flavor.unsetOptionDefaults ?? Effect.succeed([]);
71627164
const initialStart = yield* Effect.result(
71637165
startAcpRuntime(input.threadId, input.initialNativeThreadId),
71647166
);
@@ -7257,7 +7259,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
72577259
startResult: AcpSessionRuntime.AcpSessionRuntimeStartResult,
72587260
modelSelection: ModelSelection,
72597261
runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy,
7260-
newSession = false,
7262+
unsetOptionDefaults: NonNullable<ModelSelection["options"]> = [],
72617263
) {
72627264
yield* Ref.set(activeSelection, null);
72637265
yield* validateModelSelection(modelSelection);
@@ -7351,13 +7353,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
73517353
return granted !== undefined && !isRuntimeModeAbove(granted, ceiling);
73527354
};
73537355
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-
: [];
7356+
const implicitSelections = unsetOptionDefaults.filter(
7357+
(implicit) => !explicitSelections.some((selection) => selection.id === implicit.id),
7358+
);
73617359
const optionSelections = [...explicitSelections, ...implicitSelections].flatMap(
73627360
(selection) => {
73637361
if (flavor.ownedModelOptionIds?.includes(selection.id) === true) return [];
@@ -7524,7 +7522,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
75247522
started,
75257523
input.modelSelection,
75267524
input.runtimePolicy,
7527-
started.sessionId !== input.initialNativeThreadId,
7525+
started.sessionId !== input.initialNativeThreadId ? unsetOptionDefaults : [],
75287526
);
75297527
yield* Ref.set(activeSelection, input.modelSelection);
75307528
yield* Ref.set(activeInteractionMode, input.runtimePolicy.interactionMode);

0 commit comments

Comments
 (0)