From aa1bcd5b237979cbf7425dca758802caa0008489 Mon Sep 17 00:00:00 2001 From: Sri Pasumarthi Date: Thu, 7 May 2026 14:08:29 -0700 Subject: [PATCH] feat(acp): allow ask_user tool in ACP mode for Xcode users In ACP (Agent Client Protocol) mode, the `ask_user` tool is generally excluded because most IDE clients intercept tool executions, which can disrupt conversational flows. However, Xcode integrations rely on this tool being available for interactive human-in-the-loop prompts. This change: - Evaluates the host IDE using `detectIdeFromEnv().name`. - Exempts Xcode ('xcode') from the `ask_user` exclusion block during configuration loading. - Adds a unit test to `config.test.ts` to verify that the tool is not excluded when the editor is detected as Xcode. --- packages/cli/src/config/config.test.ts | 13 +++++++++++++ packages/cli/src/config/config.ts | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/config/config.test.ts b/packages/cli/src/config/config.test.ts index 9cb48dfc7b..0dab37e5f3 100644 --- a/packages/cli/src/config/config.test.ts +++ b/packages/cli/src/config/config.test.ts @@ -2506,6 +2506,19 @@ describe('loadCliConfig tool exclusions', () => { expect(config.getExcludeTools()).toContain('ask_user'); }); + it('should NOT exclude ask_user in interactive mode when --acp is provided and Xcode is detected', async () => { + process.stdin.isTTY = true; + process.argv = ['node', 'script.js', '--acp']; + vi.stubEnv('XCODE_VERSION_ACTUAL', '15.0'); + const argv = await parseArguments(createTestMergedSettings()); + const config = await loadCliConfig( + createTestMergedSettings(), + 'test-session', + argv, + ); + expect(config.getExcludeTools()).not.toContain('ask_user'); + }); + it('should not exclude shell tool in non-interactive mode when --allowed-tools="ShellTool" is set', async () => { process.stdin.isTTY = false; process.argv = [ diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index 389fc4d2a7..08ea9ce073 100755 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -809,12 +809,13 @@ export async function loadCliConfig( // In non-interactive mode, exclude tools that require a prompt. const extraExcludes: string[] = []; - if (!interactive || isAcpMode) { + const isXcode = detectIdeFromEnv().name === 'xcode'; + if (!interactive || (isAcpMode && !isXcode)) { // The Policy Engine natively handles headless safety by translating ASK_USER // decisions to DENY. However, we explicitly block ask_user here to guarantee // it can never be allowed via a high-priority policy rule when no human is present. // We also exclude it in ACP mode as IDEs intercept tool calls and ask for permission, - // breaking conversational flows. + // breaking conversational flows (except for Xcode). extraExcludes.push(ASK_USER_TOOL_NAME); }