Skip to content

fix: Allow tool names that start with numbers #407

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

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

zastrowm
Copy link
Member

@zastrowm zastrowm commented Jul 10, 2025

Description

Some MCP servers return tool names that have numeric identifiers that start with a number; open up our regex to allow those names.

This will not allow direct method invocations of those tools, but we can revisit the need for that in the future if it become a concern.

Related Issues

N/A

Documentation PR

N/A

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Ran the following conformance tests and it passed in all except llama (I have no key to test) and ollama (I'm currently pulling the model):

def test_tool_name_number(model):
    @tool(name="5get_default_data")
    def get_default_data():
        """Get the default data."""
        return "19"

    agent = Agent(model, tools=[get_default_data],
                  system_prompt="Use tool or function calls to answer as many questions as you can")
    response = agent("What is the default data?")
    assert "19" in str(response)

def test_tool_name_underscore(model):
    @tool(name="_get_default_data")
    def get_default_data():
        """Get the default data."""
        return "19"

    agent = Agent(model, tools=[get_default_data],
                  system_prompt="Use tool or function calls to answer as many questions as you can")
    response = agent("What is the default data?")
    assert "19" in str(response)

def test_numeric_tool_names_allowed_any(model):
    @tool(name="get_default_data")
    def get_default_data():
        """Get the default data."""
        return "19"

    agent = Agent(model, tools=[get_default_data], system_prompt="Use tool or function calls to answer as many questions as you can")
    response = agent("What is the default data?")
    assert "19" in str(response)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

zastrowm added 2 commits July 10, 2025 10:45
Some MCP servers return tool names that have numeric identifiers that start with a number; open up our regex to allow those names.

This will not allow direct method invocations of those tools, but we can revisit the need for that in the future if it become a concern.
Some MCP servers return tool names that have numeric identifiers that start with a number; open up our regex to allow those names.

This will not allow direct method invocations of those tools, but we can revisit the need for that in the future if it become a concern.
@zastrowm zastrowm merged commit 80de60e into strands-agents:main Jul 10, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants