-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
area:mcpRelates to Model Context Protocol (MCP)Relates to Model Context Protocol (MCP)kind:bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Description
Bug
generateToolsSystemMessage() in buildToolsSystemMessage.ts duplicates all built-in tools in the system prompt when any MCP/dynamic tool is present.
Root cause
Line 43 iterates tools (all tools) instead of withDynamicMessage (only tools without systemMessageDescription). When the withDynamicMessage.length > 0 branch fires, every tool — including built-in ones already listed via createSystemMessageExampleCall — gets a second listing via toolToSystemToolDefinition.
Built-in tools appear twice:
- In the predefined section (via
systemMessageDescription.prefix+ example call) - In the dynamic section (via
toolToSystemToolDefinition)
Impact
- Wastes context tokens with duplicate definitions
- Sends contradictory format information (predefined uses example calls, dynamic uses tool_definition blocks)
- Disproportionately affects local models with smaller context windows
- Dormant without MCP tools — only triggers when dynamic tools are registered alongside built-in tools
Fix
One-line change: for (const tool of tools) → for (const tool of withDynamicMessage)
The withDynamicMessage array is already computed on line 18-20 for exactly this purpose.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:mcpRelates to Model Context Protocol (MCP)Relates to Model Context Protocol (MCP)kind:bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Type
Projects
Status
Done