fix: Exclude web-fetch tool from executing in default non-interactive mode to avoid CLI hang. (#14244)

This commit is contained in:
Mayur Vaid
2025-12-01 22:43:14 +05:30
committed by GitHub
parent 2fe609cb62
commit 4228a75186
2 changed files with 27 additions and 0 deletions

View File

@@ -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 = [

View File

@@ -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];