You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
0.1.2
Python Version
3.12
Operating System
macos
Installation Method
pip
Steps to Reproduce
Add a tool with a hyphen in the name
from strands import Agent, tool
@tool(name="example-tool")
def example_tool():
return "done"
agent = Agent(
tools=[example_tool],
model=ollama_model,
)
agent.tool.example_tool() # doesn't work to call the function
agent.tool.example-tool() # not valid syntax
Notice that there's no way to directly invoke that tool
Expected Behavior
There should be a way to invoke a tool with a hyphen in the name
Actual Behavior
There is no way
Additional Context
No response
Possible Solution
Allow subscripting of any name by implementing __getitem__ for looking up tools. That would enable this format:
agent.tool["example-tool"]()
Alternatively, we could normalize the name of tools with dashes to underscores:
agent.tool.example_tool()
The only downside there would be if there are two tools with similar names, but that's probably rare enough to not be a significant issue.
zastrowm
changed the title
[BUG] Unable to directly invoke tools with a tool-name
[BUG] Unable to directly invoke tools with a hyphen with the tool name
May 29, 2025
Enable direct method tool invocations of `example_tool` to match tools with the name of `example-tool`, which fixesstrands-agents#139. In the case where no direct match is found but multiple tools would match, we throw an error to avoid ambiguous errors
Uh oh!
There was an error while loading. Please reload this page.
Checks
Strands Version
0.1.2
Python Version
3.12
Operating System
macos
Installation Method
pip
Steps to Reproduce
Add a tool with a hyphen in the name
Notice that there's no way to directly invoke that tool
Expected Behavior
There should be a way to invoke a tool with a hyphen in the name
Actual Behavior
There is no way
Additional Context
No response
Possible Solution
Allow subscripting of any name by implementing
__getitem__
for looking up tools. That would enable this format:Alternatively, we could normalize the name of tools with dashes to underscores:
The only downside there would be if there are two tools with similar names, but that's probably rare enough to not be a significant issue.
Related Issues
#54
The text was updated successfully, but these errors were encountered: