From bc258eba4c4ac1bb93b40729e3b09023709d881d Mon Sep 17 00:00:00 2001 From: Christian Gunderman Date: Thu, 29 Jan 2026 18:24:35 +0000 Subject: [PATCH] Cleanup post delegate_to_agent removal (#17875) --- docs/core/policy-engine.md | 6 ++-- evals/generalist_agent.eval.ts | 4 +-- .../src/ui/hooks/atCommandProcessor.test.ts | 29 +++++++++++++++++++ .../cli/src/ui/hooks/atCommandProcessor.ts | 3 +- packages/core/src/policy/policies/agent.toml | 4 --- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/docs/core/policy-engine.md b/docs/core/policy-engine.md index ee76c73874..f09ca01b70 100644 --- a/docs/core/policy-engine.md +++ b/docs/core/policy-engine.md @@ -295,9 +295,9 @@ The Gemini CLI ships with a set of default policies to provide a safe out-of-the-box experience. - **Read-only tools** (like `read_file`, `glob`) are generally **allowed**. -- **Agent delegation** (like `delegate_to_agent`) defaults to **`ask_user`** to - ensure remote agents can prompt for confirmation, but local sub-agent actions - are executed silently and checked individually. +- **Agent delegation** defaults to **`ask_user`** to ensure remote agents can + prompt for confirmation, but local sub-agent actions are executed silently and + checked individually. - **Write tools** (like `write_file`, `run_shell_command`) default to **`ask_user`**. - In **`yolo`** mode, a high-priority rule allows all tools. diff --git a/evals/generalist_agent.eval.ts b/evals/generalist_agent.eval.ts index 5a51a925cb..8161e33156 100644 --- a/evals/generalist_agent.eval.ts +++ b/evals/generalist_agent.eval.ts @@ -24,11 +24,11 @@ describe('generalist_agent', () => { prompt: 'Please use the generalist agent to create a file called "generalist_test_file.txt" containing exactly the following text: success', assert: async (rig) => { - // 1) Verify the generalist agent was invoked via delegate_to_agent + // 1) Verify the generalist agent was invoked const foundToolCall = await rig.waitForToolCall('generalist'); expect( foundToolCall, - 'Expected to find a delegate_to_agent tool call for generalist agent', + 'Expected to find a tool call for generalist agent', ).toBeTruthy(); // 2) Verify the file was created as expected diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts index c7fb584477..e66afa74a0 100644 --- a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts @@ -45,6 +45,7 @@ describe('handleAtCommand', () => { } beforeEach(async () => { + vi.restoreAllMocks(); vi.resetAllMocks(); testRootDir = await fsPromises.mkdtemp( @@ -1403,4 +1404,32 @@ describe('handleAtCommand', () => { 134, ); }); + + it('should include agent nudge when agents are found', async () => { + const agentName = 'my-agent'; + const otherAgent = 'other-agent'; + + // Mock getAgentRegistry on the config + mockConfig.getAgentRegistry = vi.fn().mockReturnValue({ + getDefinition: (name: string) => + name === agentName || name === otherAgent ? { name } : undefined, + }); + + const query = `@${agentName} @${otherAgent}`; + + const result = await handleAtCommand({ + query, + config: mockConfig, + addItem: mockAddItem, + onDebugMessage: mockOnDebugMessage, + messageId: 600, + signal: abortController.signal, + }); + + const expectedNudge = `\n\nThe user has explicitly selected the following agent(s): ${agentName}, ${otherAgent}. Please use the following tool(s) to delegate the task: '${agentName}', '${otherAgent}'.\n\n`; + + expect(result.processedQuery).toContainEqual( + expect.objectContaining({ text: expectedNudge }), + ); + }); }); diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.ts b/packages/cli/src/ui/hooks/atCommandProcessor.ts index 91ef84642e..856b7f8ecf 100644 --- a/packages/cli/src/ui/hooks/atCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/atCommandProcessor.ts @@ -457,9 +457,10 @@ export async function handleAtCommand({ const processedQueryParts: PartListUnion = [{ text: initialQueryText }]; if (agentsFound.length > 0) { + const toolsList = agentsFound.map((agent) => `'${agent}'`).join(', '); const agentNudge = `\n\nThe user has explicitly selected the following agent(s): ${agentsFound.join( ', ', - )}. Please use the 'delegate_to_agent' tool to delegate the task to the selected agent(s).\n\n`; + )}. Please use the following tool(s) to delegate the task: ${toolsList}.\n\n`; processedQueryParts.push({ text: agentNudge }); } diff --git a/packages/core/src/policy/policies/agent.toml b/packages/core/src/policy/policies/agent.toml index 218f2dc986..6c9711e8c4 100644 --- a/packages/core/src/policy/policies/agent.toml +++ b/packages/core/src/policy/policies/agent.toml @@ -25,7 +25,3 @@ # 50: Read-only tools (becomes 1.050 in default tier) # 999: YOLO mode allow-all (becomes 1.999 in default tier) -[[rule]] -toolName = "delegate_to_agent" -decision = "ask_user" -priority = 50