Skip to content

Commit 6de770c

Browse files
fix(server): ACP retries a config option whose write failed for a reason other than refusal (pingdotgg#34782)
1 parent 8212aaa commit 6de770c

2 files changed

Lines changed: 64 additions & 6 deletions

File tree

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

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ describe("AcpRegistryAdapterV2", () => {
476476
readonly storedModePick?: string;
477477
readonly turnModels?: ReadonlyArray<string>;
478478
readonly rejectedModel?: string;
479+
readonly storedOptions?: ReadonlyArray<{ readonly id: string; readonly value: string }>;
480+
readonly failsConfiguration?: boolean;
479481
}) {
480482
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
481483
// Scope release gives the replay agent at most a second to exit, so the status
@@ -563,6 +565,7 @@ describe("AcpRegistryAdapterV2", () => {
563565
...(input.storedModePick === undefined
564566
? {}
565567
: { options: [{ id: ACP_SESSION_MODE_OPTION_ID, value: input.storedModePick }] }),
568+
...(input.storedOptions === undefined ? {} : { options: input.storedOptions }),
566569
};
567570
const configurations: Array<AcpRegistryLiveConfiguration | undefined> = [];
568571
yield* Effect.gen(function* () {
@@ -616,13 +619,17 @@ describe("AcpRegistryAdapterV2", () => {
616619
}).pipe(
617620
Effect.match({
618621
onFailure: (error) => {
622+
if (input.failsConfiguration === true) return;
619623
assert.isDefined(input.rejectedModel);
620624
assert.equal(
621625
makeProviderFailure({ cause: error }).message,
622626
`The agent did not accept the model "${input.rejectedModel}". Choose another model for this provider, then retry.`,
623627
);
624628
},
625-
onSuccess: () => assert.isUndefined(input.rejectedModel),
629+
onSuccess: () => {
630+
assert.isUndefined(input.rejectedModel);
631+
assert.notEqual(input.failsConfiguration, true, "configuration should have failed");
632+
},
626633
}),
627634
Effect.scoped,
628635
);
@@ -903,6 +910,55 @@ describe("AcpRegistryAdapterV2", () => {
903910
);
904911
}).pipe(Effect.provide(layerTest), Effect.scoped),
905912
);
913+
it.effect(
914+
"fails configuration when an option write errors for a reason other than refusal",
915+
() => {
916+
const sessionModel = (currentValue: string) => ({
917+
...modelOption("model", currentValue),
918+
options: ["default", "named"].map((value) => ({ value, name: value })),
919+
});
920+
const thinking = {
921+
id: "thinking",
922+
name: "Thinking",
923+
category: "thought_level",
924+
type: "select",
925+
currentValue: "low",
926+
options: ["low", "high"].map((value) => ({ value, name: value })),
927+
};
928+
return openWithStoredPicks({
929+
setup: { configOptions: [sessionModel("default")] },
930+
storedModel: "named",
931+
storedOptions: [
932+
{ id: "thinking", value: "high" },
933+
{ id: "unavailable", value: "x" },
934+
],
935+
failsConfiguration: true,
936+
pickFrames: [
937+
outbound("session/set_config_option", {
938+
sessionId: "agent-session",
939+
configId: "model",
940+
value: "named",
941+
}),
942+
answer("session/set_config_option", {
943+
configOptions: [sessionModel("named"), thinking],
944+
}),
945+
outbound("session/set_config_option", {
946+
sessionId: "agent-session",
947+
configId: "thinking",
948+
value: "high",
949+
}),
950+
{
951+
type: "emit_inbound",
952+
frame: {
953+
kind: "response",
954+
method: "session/set_config_option",
955+
error: { code: -32603, message: "Internal error" },
956+
},
957+
},
958+
],
959+
}).pipe(Effect.provide(layerTest), Effect.scoped);
960+
},
961+
);
906962
const modelOptions = [
907963
{ id: "fast", name: "Fast", category: "model", type: "boolean", currentValue: false },
908964
{

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7391,11 +7391,13 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
73917391
yield* runtime.setConfigOption(selection.id, selection.value).pipe(
73927392
Effect.catchTags({
73937393
AcpRequestError: (error) =>
7394-
Effect.logWarning("ACP session rejected a configuration option value", {
7395-
optionId: selection.id,
7396-
value: selection.value,
7397-
detail: error.message,
7398-
}),
7394+
error.code === -32602
7395+
? Effect.logWarning("ACP session rejected a configuration option value", {
7396+
optionId: selection.id,
7397+
value: selection.value,
7398+
detail: error.message,
7399+
})
7400+
: Effect.fail(error),
73997401
}),
74007402
);
74017403
}

0 commit comments

Comments
 (0)