mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
Fix subagent break.
This commit is contained in:
@@ -9,12 +9,18 @@ import { GeneralistAgent } from './generalist-agent.js';
|
|||||||
import { makeFakeConfig } from '../test-utils/config.js';
|
import { makeFakeConfig } from '../test-utils/config.js';
|
||||||
import type { ToolRegistry } from '../tools/tool-registry.js';
|
import type { ToolRegistry } from '../tools/tool-registry.js';
|
||||||
import type { AgentRegistry } from './registry.js';
|
import type { AgentRegistry } from './registry.js';
|
||||||
|
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
|
||||||
|
|
||||||
describe('GeneralistAgent', () => {
|
describe('GeneralistAgent', () => {
|
||||||
it('should create a valid generalist agent definition', () => {
|
it('should create a valid generalist agent definition', () => {
|
||||||
const config = makeFakeConfig();
|
const config = makeFakeConfig();
|
||||||
vi.spyOn(config, 'getToolRegistry').mockReturnValue({
|
vi.spyOn(config, 'getToolRegistry').mockReturnValue({
|
||||||
getAllToolNames: () => ['tool1', 'tool2', 'agent-tool'],
|
getAllToolNames: () => ['tool1', 'tool2', 'agent-tool'],
|
||||||
|
getAllTools: () => [
|
||||||
|
{ name: 'tool1' },
|
||||||
|
{ name: 'tool2' },
|
||||||
|
{ name: 'agent-tool' },
|
||||||
|
],
|
||||||
} as unknown as ToolRegistry);
|
} as unknown as ToolRegistry);
|
||||||
vi.spyOn(config, 'getAgentRegistry').mockReturnValue({
|
vi.spyOn(config, 'getAgentRegistry').mockReturnValue({
|
||||||
getDirectoryContext: () => 'mock directory context',
|
getDirectoryContext: () => 'mock directory context',
|
||||||
@@ -34,4 +40,20 @@ describe('GeneralistAgent', () => {
|
|||||||
// Ensure it's non-interactive
|
// Ensure it's non-interactive
|
||||||
expect(agent.promptConfig.systemPrompt).toContain('non-interactive');
|
expect(agent.promptConfig.systemPrompt).toContain('non-interactive');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use fully qualified names for MCP tools', () => {
|
||||||
|
const config = makeFakeConfig();
|
||||||
|
const mockMcpTool = Object.create(DiscoveredMCPTool.prototype);
|
||||||
|
mockMcpTool.getFullyQualifiedName = () => 'server__tool';
|
||||||
|
mockMcpTool.name = 'tool';
|
||||||
|
|
||||||
|
vi.spyOn(config, 'getToolRegistry').mockReturnValue({
|
||||||
|
getAllTools: () => [{ name: 'normal-tool' }, mockMcpTool],
|
||||||
|
} as unknown as ToolRegistry);
|
||||||
|
|
||||||
|
const agent = GeneralistAgent(config);
|
||||||
|
|
||||||
|
expect(agent.toolConfig?.tools).toContain('normal-tool');
|
||||||
|
expect(agent.toolConfig?.tools).toContain('server__tool');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { z } from 'zod';
|
|||||||
import type { Config } from '../config/config.js';
|
import type { Config } from '../config/config.js';
|
||||||
import { getCoreSystemPrompt } from '../core/prompts.js';
|
import { getCoreSystemPrompt } from '../core/prompts.js';
|
||||||
import type { LocalAgentDefinition } from './types.js';
|
import type { LocalAgentDefinition } from './types.js';
|
||||||
|
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
|
||||||
|
|
||||||
const GeneralistAgentSchema = z.object({
|
const GeneralistAgentSchema = z.object({
|
||||||
response: z.string().describe('The final response from the agent.'),
|
response: z.string().describe('The final response from the agent.'),
|
||||||
@@ -48,7 +49,15 @@ export const GeneralistAgent = (
|
|||||||
model: 'inherit',
|
model: 'inherit',
|
||||||
},
|
},
|
||||||
get toolConfig() {
|
get toolConfig() {
|
||||||
const tools = config.getToolRegistry().getAllToolNames();
|
const tools = config
|
||||||
|
.getToolRegistry()
|
||||||
|
.getAllTools()
|
||||||
|
.map((tool) => {
|
||||||
|
if (tool instanceof DiscoveredMCPTool) {
|
||||||
|
return tool.getFullyQualifiedName();
|
||||||
|
}
|
||||||
|
return tool.name;
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
tools,
|
tools,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user