mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 13:53:02 -07:00
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.
This commit is contained in:
@@ -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 = [
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user