-
Notifications
You must be signed in to change notification settings - Fork 236
Labels
bugSomething isn't workingSomething isn't working
Description
Checks
- I have updated to the lastest minor and patch version of StrandsI have checked the documentation and this is not expected behaviorI have searched ./issues and there are no duplicates of my issueTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
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
michaellandi
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
[-][BUG] Unable to directly invoke tools with a tool-name[/-][+][BUG] Unable to directly invoke tools with a hyphen with the tool name[/+]Fix: Enable underscores in direct method invocations to match hyphens
Fix: Enable underscores in direct method invocations to match hyphens
Fix: Enable underscores in direct method invocations to match hyphens (…
Fix: Enable underscores in direct method invocations to match hyphens (…
Fix: Enable underscores in direct method invocations to match hyphens (…