From 4228a75186f5f375d135772966d5b96be0455774 Mon Sep 17 00:00:00 2001 From: Mayur Vaid <34806097+MayV@users.noreply.github.com> Date: Mon, 1 Dec 2025 22:43:14 +0530 Subject: [PATCH] fix: Exclude web-fetch tool from executing in default non-interactive mode to avoid CLI hang. (#14244) --- packages/cli/src/config/config.test.ts | 25 +++++++++++++++++++++++++ packages/cli/src/config/config.ts | 2 ++ 2 files changed, 27 insertions(+) diff --git a/packages/cli/src/config/config.test.ts b/packages/cli/src/config/config.test.ts index 3e66fcebbf..bfb6967bef 100644 --- a/packages/cli/src/config/config.test.ts +++ b/packages/cli/src/config/config.test.ts @@ -13,6 +13,7 @@ import { SHELL_TOOL_NAME, WRITE_FILE_TOOL_NAME, EDIT_TOOL_NAME, + WEB_FETCH_TOOL_NAME, type ExtensionLoader, debugLogger, } from '@google/gemini-cli-core'; @@ -767,6 +768,7 @@ describe('mergeExcludeTools', () => { SHELL_TOOL_NAME, EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME, + WEB_FETCH_TOOL_NAME, ]); const originalIsTTY = process.stdin.isTTY; @@ -1645,6 +1647,29 @@ describe('loadCliConfig tool exclusions', () => { expect(config.getExcludeTools()).not.toContain(SHELL_TOOL_NAME); }); + it('should exclude web-fetch in non-interactive mode when not allowed', async () => { + process.stdin.isTTY = false; + process.argv = ['node', 'script.js', '-p', 'test']; + const argv = await parseArguments({} as Settings); + const config = await loadCliConfig({}, 'test-session', argv); + expect(config.getExcludeTools()).toContain(WEB_FETCH_TOOL_NAME); + }); + + it('should not exclude web-fetch in non-interactive mode when allowed', async () => { + process.stdin.isTTY = false; + process.argv = [ + 'node', + 'script.js', + '-p', + 'test', + '--allowed-tools', + WEB_FETCH_TOOL_NAME, + ]; + const argv = await parseArguments({} as Settings); + const config = await loadCliConfig({}, 'test-session', argv); + expect(config.getExcludeTools()).not.toContain(WEB_FETCH_TOOL_NAME); + }); + it('should not exclude shell tool in non-interactive mode when --allowed-tools="run_shell_command" 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 7e4f1cd4d0..3a85a0760a 100755 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -29,6 +29,7 @@ import { EDIT_TOOL_NAME, debugLogger, loadServerHierarchicalMemory, + WEB_FETCH_TOOL_NAME, } from '@google/gemini-cli-core'; import type { Settings } from './settings.js'; @@ -530,6 +531,7 @@ export async function loadCliConfig( SHELL_TOOL_NAME, EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME, + WEB_FETCH_TOOL_NAME, ]; const autoEditExcludes = [SHELL_TOOL_NAME];