Skip to content

[BUG] Unable to directly invoke tools with a hyphen with the tool name #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
zastrowm opened this issue May 29, 2025 · 0 comments · May be fixed by #178
Open
3 tasks done

[BUG] Unable to directly invoke tools with a hyphen with the tool name #139

zastrowm opened this issue May 29, 2025 · 0 comments · May be fixed by #178
Assignees
Labels
bug Something isn't working

Comments

@zastrowm
Copy link
Member

zastrowm commented May 29, 2025

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

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.

Related Issues

#54

@zastrowm zastrowm added the bug Something isn't working label May 29, 2025
@zastrowm 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
zastrowm added a commit to zastrowm/sdk-python that referenced this issue Jun 4, 2025
Enable direct method tool invocations of `example_tool` to match tools with the name of `example-tool`, which fixes strands-agents#139. In the case where no direct match is found but multiple tools would match, we throw an error to avoid ambiguous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant