Skip to content

[BUG] @tool with no input arguments fails #599

@liorheber

Description

@liorheber

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

1.2.0

Python Version

=3.12

Operating System

MacOS 15.3

Installation Method

other

Steps to Reproduce

  1. Create a strands tool without an input argument
@tool
async def fetch_schemas() -> str:
 """Get all schemas including data sources, tables, and column information.
Returns comprehensive schema information
"""
...do something...

Expected Behavior

I expect the agent to execute the code without issues.

Actual Behavior

I get the following error -

Tool #1: fetch_schemas
cycle failed
Traceback (most recent call last):
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/event_loop/event_loop.py", line 215, in event_loop_cycle
    async for event in events:
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/event_loop/event_loop.py", line 433, in _handle_tool_execution
    validate_and_prepare_tools(message, tool_uses, tool_results, invalid_tool_use_ids)
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/tools/executor.py", line 124, in validate_and_prepare_tools
    validate_tool_use(tool)
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/tools/tools.py", line 32, in validate_tool_use
    validate_tool_use_name(tool)
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/tools/tools.py", line 53, in validate_tool_use_name
    valid_name_pattern = bool(re.match(tool_name_pattern, tool_name))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/re/__init__.py", line 167, in match
    return _compile(pattern, flags).match(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
Traceback (most recent call last):
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/event_loop/event_loop.py", line 215, in event_loop_cycle
    async for event in events:
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/event_loop/event_loop.py", line 433, in _handle_tool_execution
    validate_and_prepare_tools(message, tool_uses, tool_results, invalid_tool_use_ids)
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/tools/executor.py", line 124, in validate_and_prepare_tools
    validate_tool_use(tool)
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/tools/tools.py", line 32, in validate_tool_use
    validate_tool_use_name(tool)
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/tools/tools.py", line 53, in validate_tool_use_name
    valid_name_pattern = bool(re.match(tool_name_pattern, tool_name))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/re/__init__.py", line 167, in match
    return _compile(pattern, flags).match(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/liorheber/WebstormProjects/ai/agent/main.py", line 288, in <module>
    main()
  File "/Users/liorheber/WebstormProjects/ai/agent/main.py", line 284, in main
    agent("What schemas are available?")
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 377, in __call__
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/opentelemetry/instrumentation/threading/__init__.py", line 171, in wrapped_func
    return original_func(*func_args, **func_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 373, in execute
    return asyncio.run(self.invoke_async(prompt, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/liorheber/.local/share/uv/python/cpython-3.12.9-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 398, in invoke_async
    async for event in events:
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 508, in stream_async
    async for event in events:
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 544, in _run_loop
    async for event in events:
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 583, in _execute_event_loop_cycle
    async for event in events:
  File "/Users/liorheber/WebstormProjects/ai/agent/.venv/lib/python3.12/site-packages/strands/event_loop/event_loop.py", line 245, in event_loop_cycle
    raise EventLoopException(e, invocation_state["request_state"]) from e
strands.types.exceptions.EventLoopException: expected string or bytes-like object, got 'NoneType'

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    autoclose in 7 daysThe issue will close in 7 days if no additional comment is added.bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions