Skip to content

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

@zastrowm

Description

@zastrowm
Member

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

Activity

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[/+] on May 29, 2025
added theissue type on Jun 3, 2025
added a commit that references this issue on Jun 4, 2025
d534ac6
added a commit that references this issue on Jun 9, 2025
dd14422
added a commit that references this issue on Jun 9, 2025
aff928c
added a commit that references this issue on Jul 2, 2025
988af22
added a commit that references this issue on Jul 9, 2025
b456f62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @zastrowm

    Issue actions

      [BUG] Unable to directly invoke tools with a hyphen with the tool name · Issue #139 · strands-agents/sdk-python