Skip to content

fix: don't duplicate built-in tools in system prompt when MCP tools present#11068

Open
shanevcantwell wants to merge 1 commit intocontinuedev:mainfrom
shanevcantwell:fix/system-message-tool-dedup
Open

fix: don't duplicate built-in tools in system prompt when MCP tools present#11068
shanevcantwell wants to merge 1 commit intocontinuedev:mainfrom
shanevcantwell:fix/system-message-tool-dedup

Conversation

@shanevcantwell
Copy link
Contributor

@shanevcantwell shanevcantwell commented Mar 5, 2026

Summary

The bug

buildToolsSystemMessage.ts line 43 iterates tools (all tools) instead of withDynamicMessage (only tools without systemMessageDescription). When the withDynamicMessage.length > 0 branch fires, every built-in tool gets listed twice:

  1. In the predefined section via createSystemMessageExampleCall() (using systemMessageDescription.prefix + example args)
  2. In the dynamic section via toolToSystemToolDefinition() (using tool_definition codeblock format)

The withDynamicMessage variable is computed on lines 18-20 for exactly this purpose — it just wasn't used.

Context

Found while auditing the system message tools framework for local model compatibility. Duplicate definitions waste context tokens and send contradictory format information (predefined uses example calls, dynamic uses tool_definition blocks). Frontier models silently handle the redundancy; local models with smaller context windows are disproportionately affected.

Changes

File Change
core/tools/systemMessageTools/buildToolsSystemMessage.ts toolswithDynamicMessage on line 43
core/tools/systemMessageTools/toolCodeblocks/buildSystemMessage.vitest.ts New test asserting no duplicate tool definitions when mixed predefined + dynamic tools

Test plan

  • 11 tests passing (10 existing + 1 new dedup assertion)
  • CI

🤖 Generated with Claude Code


Continue Tasks: 🔄 7 running — View all


Summary by cubic

Fix duplicated built-in tool definitions in the system prompt when MCP/dynamic tools are present, reducing token waste and conflicting instructions. Fixes #11064 by listing only dynamic tools in the additional definitions section and adds a test to ensure no duplicates.

Written for commit 9702f31. Summary will update on new commits.

…resent

Fix continuedev#11064

When MCP/dynamic tools are registered alongside built-in tools,
generateToolsSystemMessage() listed ALL tools through toolToSystemToolDefinition
instead of only the dynamic ones. Built-in tools appeared twice — once via
their systemMessageDescription (predefined section) and again via the
dynamic section.

Found while auditing the system message tools framework for local model
compatibility. Duplicate definitions waste context tokens and send
contradictory format information that frontier models silently handle
but local models struggle with.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shanevcantwell shanevcantwell requested a review from a team as a code owner March 5, 2026 11:41
@shanevcantwell shanevcantwell requested review from RomneyDa and removed request for a team March 5, 2026 11:41
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 5, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

System message tools duplicates built-in tools when MCP tools present

1 participant