Skip to content

Conversation

JackYPCOnline
Copy link
Contributor

@JackYPCOnline JackYPCOnline commented Aug 29, 2025

Description

fix duplicate tool names, throw Value Erro while tools have same name, except tool.support_hot_reload is true.

Related Issues

#715

Documentation PR

Type of Change

Bug fix
New feature
Breaking change
Documentation update
Other (please describe):

Testing

test with aws mcp server.

stdio_mcp_client = MCPClient(lambda: stdio_client(
    StdioServerParameters(
        command="uvx",
        args=["awslabs.aws-documentation-mcp-server@latest"]
    )
))

@tool
def read_documentation():
    return ""

test_tool = None

with stdio_mcp_client:
    for tool in stdio_mcp_client.list_tools_sync():
        if tool.tool_name == "read_documentation":
            test_tool = tool
  
    agent = Agent(tools=[read_documentation,test_tool])
    print(agent.tool_names)
[08/29/25 15:32:47] INFO     Processing request of type ListToolsRequest                                                                                                                                                                                                                                    server.py:624
Jack need your name: read_documentation
Traceback (most recent call last):
  File "/Volumes/workplace/Strands/personal/agent.py", line 30, in <module>
    agent = Agent(tools=[read_documentation,test_tool])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/workplace/Strands/sdk-python/src/strands/agent/agent.py", line 312, in __init__
    self.tool_registry.process_tools(tools)
  File "/Volumes/workplace/Strands/sdk-python/src/strands/tools/registry.py", line 108, in process_tools
    add_tool(a_tool)
  File "/Volumes/workplace/Strands/sdk-python/src/strands/tools/registry.py", line 98, in add_tool
    self.register_tool(tool)
  File "/Volumes/workplace/Strands/sdk-python/src/strands/tools/registry.py", line 196, in register_tool
    raise ValueError(f"Tool name '{tool.tool_name}' already exists. "
ValueError: Tool name 'read_documentation' already exists. Cannot register tools with exact same name.

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • [x ] I ran hatch run prepare

Checklist

  • [ x] I have read the CONTRIBUTING document
  • [ x] I have added any necessary tests that prove my fix is effective or my feature works
  • [ x] I have updated the documentation accordingly
  • [ x] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • [x ] My changes generate no new warnings
  • [x ] Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@JackYPCOnline JackYPCOnline merged commit e7d95d6 into strands-agents:main Aug 29, 2025
11 of 12 checks passed
Ratish1 pushed a commit to Ratish1/sdk-python that referenced this pull request Aug 30, 2025
* fix: fix loading tools with same tool name

* simplify if condition

---------

Co-authored-by: Jack Yuan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants