Skip to content

Fix/deduplicate tool names#2278

Open
Anubhav200311 wants to merge 3 commits intodocker:mainfrom
Anubhav200311:fix/deduplicate-tool-names
Open

Fix/deduplicate tool names#2278
Anubhav200311 wants to merge 3 commits intodocker:mainfrom
Anubhav200311:fix/deduplicate-tool-names

Conversation

@Anubhav200311
Copy link
Copy Markdown

@Anubhav200311 Anubhav200311 commented Mar 30, 2026

When multiple toolsets contain tools with the same name, the Agent's Tools() method returns duplicates. This causes Anthropic API 400 errors because the API rejects requests with duplicate tool names.

This fix adds deduplication logic to the Tools() method in pkg/agent/agent.go. After all toolsets are collected, it filters out duplicate tool names, keeping the first occurrence and logging a warning for
any that are skipped. A corresponding test case ("duplicate tool names are deduplicated") is added in pkg/agent/agent_test.go to verify the behavior.
Fixes #2251

@Anubhav200311 Anubhav200311 requested a review from a team as a code owner March 30, 2026 04:52
@aheritier
Copy link
Copy Markdown
Contributor

/review

@aheritier aheritier added the kind/bug Something isn't working label Mar 30, 2026
Copy link
Copy Markdown

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Assessment: 🟡 NEEDS ATTENTION

This PR successfully fixes the duplicate tool name issue that was causing Anthropic API 400 errors. The deduplication logic is sound and will prevent the reported bug.

Findings: 1 medium-severity issue regarding inconsistent warning handling.

The deduplication warnings use slog.Warn() directly instead of addToolWarning(), which means they won't be captured by DrainWarnings(). Consider aligning with the existing warning pattern for consistency.

@Anubhav200311
Copy link
Copy Markdown
Author

Anubhav200311 commented Mar 30, 2026

Addressed the bot's feedback in the latest commit --> added addToolWarning() for consistent warning handling.

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

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate tool names across toolsets cause Anthropic 400 errors

2 participants