From 4efdbe90893a153b62ec071c1699043b86885dce Mon Sep 17 00:00:00 2001 From: sinisterchill <91934084+reyyanxahmed@users.noreply.github.com> Date: Tue, 24 Feb 2026 22:22:32 +0530 Subject: [PATCH] fix(a2a-server): pass allowedTools settings to core Config (#19680) --- packages/a2a-server/src/config/config.test.ts | 43 +++++++++++++++++++ packages/a2a-server/src/config/config.ts | 5 ++- packages/a2a-server/src/config/settings.ts | 6 +++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/packages/a2a-server/src/config/config.test.ts b/packages/a2a-server/src/config/config.test.ts index 1c6bdc38fb..e68ebc4431 100644 --- a/packages/a2a-server/src/config/config.test.ts +++ b/packages/a2a-server/src/config/config.test.ts @@ -267,4 +267,47 @@ describe('loadConfig', () => { customIgnoreFilePaths: [testPath], }); }); + + describe('tool configuration', () => { + it('should pass V1 allowedTools to Config properly', async () => { + const settings: Settings = { + allowedTools: ['shell', 'edit'], + }; + await loadConfig(settings, mockExtensionLoader, taskId); + expect(Config).toHaveBeenCalledWith( + expect.objectContaining({ + allowedTools: ['shell', 'edit'], + }), + ); + }); + + it('should pass V2 tools.allowed to Config properly', async () => { + const settings: Settings = { + tools: { + allowed: ['shell', 'fetch'], + }, + }; + await loadConfig(settings, mockExtensionLoader, taskId); + expect(Config).toHaveBeenCalledWith( + expect.objectContaining({ + allowedTools: ['shell', 'fetch'], + }), + ); + }); + + it('should prefer V1 allowedTools over V2 tools.allowed if both present', async () => { + const settings: Settings = { + allowedTools: ['v1-tool'], + tools: { + allowed: ['v2-tool'], + }, + }; + await loadConfig(settings, mockExtensionLoader, taskId); + expect(Config).toHaveBeenCalledWith( + expect.objectContaining({ + allowedTools: ['v1-tool'], + }), + ); + }); + }); }); diff --git a/packages/a2a-server/src/config/config.ts b/packages/a2a-server/src/config/config.ts index eb92e55f36..6a27bca4d5 100644 --- a/packages/a2a-server/src/config/config.ts +++ b/packages/a2a-server/src/config/config.ts @@ -68,8 +68,9 @@ export async function loadConfig( debugMode: process.env['DEBUG'] === 'true' || false, question: '', // Not used in server mode directly like CLI - coreTools: settings.coreTools || undefined, - excludeTools: settings.excludeTools || undefined, + coreTools: settings.coreTools || settings.tools?.core || undefined, + excludeTools: settings.excludeTools || settings.tools?.exclude || undefined, + allowedTools: settings.allowedTools || settings.tools?.allowed || undefined, showMemoryUsage: settings.showMemoryUsage || false, approvalMode: process.env['GEMINI_YOLO_MODE'] === 'true' diff --git a/packages/a2a-server/src/config/settings.ts b/packages/a2a-server/src/config/settings.ts index a2b11d0886..b3c44cc177 100644 --- a/packages/a2a-server/src/config/settings.ts +++ b/packages/a2a-server/src/config/settings.ts @@ -27,6 +27,12 @@ export interface Settings { mcpServers?: Record; coreTools?: string[]; excludeTools?: string[]; + allowedTools?: string[]; + tools?: { + allowed?: string[]; + exclude?: string[]; + core?: string[]; + }; telemetry?: TelemetrySettings; showMemoryUsage?: boolean; checkpointing?: CheckpointingSettings;