diff --git a/packages/core/src/agents/generalist-agent.test.ts b/packages/core/src/agents/generalist-agent.test.ts index efdf705a19..84426b926b 100644 --- a/packages/core/src/agents/generalist-agent.test.ts +++ b/packages/core/src/agents/generalist-agent.test.ts @@ -9,12 +9,18 @@ import { GeneralistAgent } from './generalist-agent.js'; import { makeFakeConfig } from '../test-utils/config.js'; import type { ToolRegistry } from '../tools/tool-registry.js'; import type { AgentRegistry } from './registry.js'; +import { DiscoveredMCPTool } from '../tools/mcp-tool.js'; describe('GeneralistAgent', () => { it('should create a valid generalist agent definition', () => { const config = makeFakeConfig(); vi.spyOn(config, 'getToolRegistry').mockReturnValue({ getAllToolNames: () => ['tool1', 'tool2', 'agent-tool'], + getAllTools: () => [ + { name: 'tool1' }, + { name: 'tool2' }, + { name: 'agent-tool' }, + ], } as unknown as ToolRegistry); vi.spyOn(config, 'getAgentRegistry').mockReturnValue({ getDirectoryContext: () => 'mock directory context', @@ -34,4 +40,20 @@ describe('GeneralistAgent', () => { // Ensure it's 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'); + }); }); diff --git a/packages/core/src/agents/generalist-agent.ts b/packages/core/src/agents/generalist-agent.ts index 1b7fc961fb..db2c56f61d 100644 --- a/packages/core/src/agents/generalist-agent.ts +++ b/packages/core/src/agents/generalist-agent.ts @@ -8,6 +8,7 @@ import { z } from 'zod'; import type { Config } from '../config/config.js'; import { getCoreSystemPrompt } from '../core/prompts.js'; import type { LocalAgentDefinition } from './types.js'; +import { DiscoveredMCPTool } from '../tools/mcp-tool.js'; const GeneralistAgentSchema = z.object({ response: z.string().describe('The final response from the agent.'), @@ -48,7 +49,15 @@ export const GeneralistAgent = ( model: 'inherit', }, 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 { tools, };