generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 453
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
1.5.0
Tools Package Version
N/A
Tools used
Custom tools
Python Version
3.11
Operating System
Amazon Linux x86_64 5.10 Kernel
Installation Method
pip
Steps to Reproduce
See code snippet below
from strands import Agent, tool
from mcp import StdioServerParameters, stdio_client
from strands.tools.mcp import MCPClient, MCPAgentTool
# Define our own 'list_leadership_principles' tool as well as a tool with a different name
@tool
def list_leadership_principles():
return """
"Ride the Void with Honor" - Maintain integrity even when no one's watching in the vast emptiness of space
"Every Crew Member's a Star" - Value each team member's unique contributions, whether they're human, android, or alien
"Navigate by Both Stars and Gut" - Balance data-driven decisions with experiential intuition when making tough calls
"Keep Your Reactor Cool" - Maintain composure under pressure, whether facing meteor storms or hostile encounters
"Salvage Ain't Stealing" - Be resourceful and innovative, but maintain ethical boundaries even when resources are scarce
"Leave Each Galaxy Better Than You Found It" - Make positive impacts wherever your journey takes you, considering long-term consequences of your actions
"""
@tool
def list_other_leadership_principles():
return """
"Your Ship is Your Word" - Honor commitments and promises as steadfastly as you maintain your spacecraft
"Dance with the Solar Winds" - Stay flexible and adaptable; sometimes the indirect route is the smartest path
"One Hand on the Laser, One Hand Extended" - Be prepared for trouble but always open to peaceful solutions and new alliances
"Share Your Space Rations" - Take care of your team; ensure everyone has what they need to survive and thrive
"Leave Each Galaxy Better Than You Found It" - Make positive impacts wherever your journey takes you, considering long-term consequences of your actions
"""
# Manually find tool with name 'list_leadership_principles' in amzn-mcp MCP server
command = "amzn-mcp"
args = []
env = {}
server_params = StdioServerParameters(
command=command,
args=args,
env=env,
)
client = MCPClient(lambda params=server_params: stdio_client(params))
lp_mcp_tool = None
with client:
for tool in client.list_tools_sync():
if tool.tool_name == "list_leadership_principles":
lp_mcp_tool = tool
# Supply tools with the same name to the agent and observe only one tool saved
tool_list = [lp_mcp_tool, list_leadership_principles]
with client:
agent = Agent(
tools = tool_list
)
print(agent.tool_names) # ['list_leadership_principles']
# Supply tools with the different names to the agent and observe both tools saved
tool_list = [lp_mcp_tool, list_other_leadership_principles]
with client:
agent = Agent(
tools = tool_list
)
print(agent.tool_names) # ['list_leadership_principles', 'list_other_leadership_principles']
Expected Behavior
I would prefer if an exception was raised. The current behavior has the potential to introduce bugs which can be pretty difficult to track down.
My thought is that if I’m supplying two different tools, I’d like them both to be used properly. Perhaps it’s an accident on my end that caused them to have the same name.
Actual Behavior
Strands silently overrides one of the tools.
Additional Context
No response
Possible Solution
No response
Related Issues
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working