mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-17 00:31:44 -07:00
feat(core): refactor subagent tool to unified invoke_subagent tool (#24489)
This commit is contained in:
@@ -67,6 +67,11 @@ describe('Policy Engine Integration Tests', () => {
|
||||
expect(
|
||||
(await engine.check({ name: 'unknown_tool' }, undefined)).decision,
|
||||
).toBe(PolicyDecision.ASK_USER);
|
||||
|
||||
// invoke_agent should be allowed by default (via agents.toml)
|
||||
expect(
|
||||
(await engine.check({ name: 'invoke_agent' }, undefined)).decision,
|
||||
).toBe(PolicyDecision.ALLOW);
|
||||
});
|
||||
|
||||
it('should handle MCP server wildcard patterns correctly', async () => {
|
||||
@@ -350,9 +355,37 @@ describe('Policy Engine Integration Tests', () => {
|
||||
(await engine.check({ name: 'get_internal_docs' }, undefined)).decision,
|
||||
).toBe(PolicyDecision.ALLOW);
|
||||
expect(
|
||||
(await engine.check({ name: 'cli_help' }, undefined)).decision,
|
||||
(
|
||||
await engine.check(
|
||||
{ name: 'invoke_agent', args: { agent_name: 'cli_help' } },
|
||||
undefined,
|
||||
)
|
||||
).decision,
|
||||
).toBe(PolicyDecision.ALLOW);
|
||||
|
||||
// codebase_investigator should be allowed in Plan mode
|
||||
expect(
|
||||
(
|
||||
await engine.check(
|
||||
{
|
||||
name: 'invoke_agent',
|
||||
args: { agent_name: 'codebase_investigator' },
|
||||
},
|
||||
undefined,
|
||||
)
|
||||
).decision,
|
||||
).toBe(PolicyDecision.ALLOW);
|
||||
|
||||
// Unknown agents should be denied in Plan mode (via catch-all)
|
||||
expect(
|
||||
(
|
||||
await engine.check(
|
||||
{ name: 'invoke_agent', args: { agent_name: 'unknown_agent' } },
|
||||
undefined,
|
||||
)
|
||||
).decision,
|
||||
).toBe(PolicyDecision.DENY);
|
||||
|
||||
// Other tools should be denied via catch all
|
||||
expect(
|
||||
(await engine.check({ name: 'replace' }, undefined)).decision,
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
CoreToolCallStatus,
|
||||
type SubagentActivityItem,
|
||||
type SubagentActivityMessage,
|
||||
AGENT_TOOL_NAME,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { useCallback, useState, useMemo, useEffect, useRef } from 'react';
|
||||
|
||||
@@ -253,7 +254,7 @@ export function useToolScheduler(
|
||||
const flattened = Object.values(toolCallsMap).flat();
|
||||
return flattened.map((tc) => {
|
||||
let subagentName = tc.request.name;
|
||||
if (tc.request.name === 'invoke_subagent') {
|
||||
if (tc.request.name === AGENT_TOOL_NAME) {
|
||||
const argsObj = tc.request.args;
|
||||
let parsedArgs: unknown = argsObj;
|
||||
|
||||
@@ -267,7 +268,7 @@ export function useToolScheduler(
|
||||
|
||||
if (typeof parsedArgs === 'object' && parsedArgs !== null) {
|
||||
for (const [key, value] of Object.entries(parsedArgs)) {
|
||||
if (key === 'subagent_name' && typeof value === 'string') {
|
||||
if (key === 'agent_name' && typeof value === 'string') {
|
||||
subagentName = value;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user