mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-02-01 14:44:29 +00:00
Cleanup post delegate_to_agent removal (#17875)
This commit is contained in:
committed by
GitHub
parent
0e30055ae4
commit
bc258eba4c
@@ -295,9 +295,9 @@ The Gemini CLI ships with a set of default policies to provide a safe
|
|||||||
out-of-the-box experience.
|
out-of-the-box experience.
|
||||||
|
|
||||||
- **Read-only tools** (like `read_file`, `glob`) are generally **allowed**.
|
- **Read-only tools** (like `read_file`, `glob`) are generally **allowed**.
|
||||||
- **Agent delegation** (like `delegate_to_agent`) defaults to **`ask_user`** to
|
- **Agent delegation** defaults to **`ask_user`** to ensure remote agents can
|
||||||
ensure remote agents can prompt for confirmation, but local sub-agent actions
|
prompt for confirmation, but local sub-agent actions are executed silently and
|
||||||
are executed silently and checked individually.
|
checked individually.
|
||||||
- **Write tools** (like `write_file`, `run_shell_command`) default to
|
- **Write tools** (like `write_file`, `run_shell_command`) default to
|
||||||
**`ask_user`**.
|
**`ask_user`**.
|
||||||
- In **`yolo`** mode, a high-priority rule allows all tools.
|
- In **`yolo`** mode, a high-priority rule allows all tools.
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ describe('generalist_agent', () => {
|
|||||||
prompt:
|
prompt:
|
||||||
'Please use the generalist agent to create a file called "generalist_test_file.txt" containing exactly the following text: success',
|
'Please use the generalist agent to create a file called "generalist_test_file.txt" containing exactly the following text: success',
|
||||||
assert: async (rig) => {
|
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');
|
const foundToolCall = await rig.waitForToolCall('generalist');
|
||||||
expect(
|
expect(
|
||||||
foundToolCall,
|
foundToolCall,
|
||||||
'Expected to find a delegate_to_agent tool call for generalist agent',
|
'Expected to find a tool call for generalist agent',
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
|
|
||||||
// 2) Verify the file was created as expected
|
// 2) Verify the file was created as expected
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ describe('handleAtCommand', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
vi.restoreAllMocks();
|
||||||
vi.resetAllMocks();
|
vi.resetAllMocks();
|
||||||
|
|
||||||
testRootDir = await fsPromises.mkdtemp(
|
testRootDir = await fsPromises.mkdtemp(
|
||||||
@@ -1403,4 +1404,32 @@ describe('handleAtCommand', () => {
|
|||||||
134,
|
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<system_note>\nThe user has explicitly selected the following agent(s): ${agentName}, ${otherAgent}. Please use the following tool(s) to delegate the task: '${agentName}', '${otherAgent}'.\n</system_note>\n`;
|
||||||
|
|
||||||
|
expect(result.processedQuery).toContainEqual(
|
||||||
|
expect.objectContaining({ text: expectedNudge }),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -457,9 +457,10 @@ export async function handleAtCommand({
|
|||||||
const processedQueryParts: PartListUnion = [{ text: initialQueryText }];
|
const processedQueryParts: PartListUnion = [{ text: initialQueryText }];
|
||||||
|
|
||||||
if (agentsFound.length > 0) {
|
if (agentsFound.length > 0) {
|
||||||
|
const toolsList = agentsFound.map((agent) => `'${agent}'`).join(', ');
|
||||||
const agentNudge = `\n<system_note>\nThe user has explicitly selected the following agent(s): ${agentsFound.join(
|
const agentNudge = `\n<system_note>\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</system_note>\n`;
|
)}. Please use the following tool(s) to delegate the task: ${toolsList}.\n</system_note>\n`;
|
||||||
processedQueryParts.push({ text: agentNudge });
|
processedQueryParts.push({ text: agentNudge });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,3 @@
|
|||||||
# 50: Read-only tools (becomes 1.050 in default tier)
|
# 50: Read-only tools (becomes 1.050 in default tier)
|
||||||
# 999: YOLO mode allow-all (becomes 1.999 in default tier)
|
# 999: YOLO mode allow-all (becomes 1.999 in default tier)
|
||||||
|
|
||||||
[[rule]]
|
|
||||||
toolName = "delegate_to_agent"
|
|
||||||
decision = "ask_user"
|
|
||||||
priority = 50
|
|
||||||
|
|||||||
Reference in New Issue
Block a user