From 25ccadd22a339e24bf778dd84fecd20e61df3fe9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 24 May 2026 01:18:05 +0100 Subject: [PATCH] fix(acp): require allow option for auto approvals --- src/acp/client-helpers.ts | 7 +++---- src/acp/client.test.ts | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/acp/client-helpers.ts b/src/acp/client-helpers.ts index 68da8b1aead..891274293a2 100644 --- a/src/acp/client-helpers.ts +++ b/src/acp/client-helpers.ts @@ -123,13 +123,12 @@ export async function resolvePermissionRequest( const promptRequired = !classification.autoApprove; if (!promptRequired) { - const option = allowOption ?? options[0]; - if (!option) { - log(`[permission cancelled] ${toolName}: no selectable options`); + if (!allowOption) { + log(`[permission cancelled] ${toolName ?? "unknown"}: missing allow option`); return cancelledPermission(); } log(`[permission auto-approved] ${toolName} (${toolKind ?? "unknown"})`); - return selectedPermission(option.optionId); + return selectedPermission(allowOption.optionId); } log( diff --git a/src/acp/client.test.ts b/src/acp/client.test.ts index 3e54b6822b9..2ff5d18b0cb 100644 --- a/src/acp/client.test.ts +++ b/src/acp/client.test.ts @@ -659,6 +659,27 @@ describe("resolvePermissionRequest", () => { expect(res).toEqual({ outcome: { outcome: "selected", optionId: "reject-always" } }); }); + it("cancels auto-approved requests when no allow option is available", async () => { + const prompt = vi.fn(async () => true); + const log = vi.fn(); + const res = await resolvePermissionRequest( + makePermissionRequest({ + toolCall: { + toolCallId: "tool-read-no-allow", + title: "read: src/index.ts", + status: "pending", + kind: "read", + }, + options: [{ kind: "reject_once", name: "Reject", optionId: "reject" }], + }), + { prompt, log }, + ); + + expect(prompt).not.toHaveBeenCalled(); + expect(log).toHaveBeenCalledWith("[permission cancelled] read: missing allow option"); + expect(res).toEqual({ outcome: { outcome: "cancelled" } }); + }); + it("prompts when tool identity is unknown and can still approve", async () => { const prompt = vi.fn(async () => true); const res = await resolvePermissionRequest(