Skip to content

[BUG] 0.1.7 Pydantic @tool parameter regression #216

Open
@JoshuaToth

Description

@JoshuaToth

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.7

Python Version

3.13.2

Operating System

macOS (Also Lambda)

Installation Method

pip

Steps to Reproduce

  1. Install strands-agents version 0.1.7

  2. run the below in an index.py

from pydantic import BaseModel
from strands import Agent, tool, models


class StoryboardEntry(BaseModel):
    sceneIndex: int
    sceneDescription: str
    sceneType: str


@tool
def save_full_storyboard(storyboard_data: StoryboardEntry):
    print(storyboard_data)
    return "done"


bedrock_model = models.BedrockModel(
    model="anthropic.claude-3-5-sonnet-20241022-v2:0",
    max_tokens=40000,
    region_name="us-west-2"
)

agent = Agent(
        model=bedrock_model,
        tools=[save_full_storyboard]
    )

agent("Your task is to generate a children's novel storyboard scene")

Expected Behavior

Pydantic types can be used as method parameter.

Actual Behavior

Tool error:

botocore.exceptions.EventStreamError: An error occurred (validationException) when calling the ConverseStream operation: The model returned the following errors: tools.0.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12 (https://json-schema.org/draft/2020-12). Learn more about tool use at https://docs.anthropic.com/en/docs/tool-use.

Full stacktrace

Traceback (most recent call last):
  File "/Users/joshtoth/dev/strands-test/index.py", line 29, in <module>
    agent("Your task is to generate a childrens novel storyboard")
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/agent/agent.py", line 358, in __call__
    result = self._run_loop(prompt, kwargs)
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/agent/agent.py", line 462, in _run_loop
    return self._execute_event_loop_cycle(invocation_callback_handler, kwargs)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/agent/agent.py", line 490, in _execute_event_loop_cycle
    stop_reason, message, metrics, state = event_loop_cycle(
                                           ~~~~~~~~~~~~~~~~^
        model=model,
        ^^^^^^^^^^^^
    ...<9 lines>...
        **kwargs,
        ^^^^^^^^^
    )
    ^
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 190, in event_loop_cycle
    raise e
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 148, in event_loop_cycle
    stop_reason, message, usage, metrics, kwargs["request_state"] = stream_messages(
                                                                    ~~~~~~~~~~~~~~~^
        model,
        ^^^^^^
    ...<4 lines>...
        **kwargs,
        ^^^^^^^^^
    )
    ^
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 340, in stream_messages
    return process_stream(chunks, callback_handler, messages, **kwargs)
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 290, in process_stream
    for chunk in chunks:
                 ^^^^^^
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/types/models/model.py", line 115, in converse
    for event in response:
                 ^^^^^^^^
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/models/bedrock.py", line 369, in stream
    raise e
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/strands/models/bedrock.py", line 331, in stream
    for chunk in response["stream"]:
                 ~~~~~~~~^^^^^^^^^^
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/botocore/eventstream.py", line 592, in __iter__
    parsed_event = self._parse_event(event)
  File "/Users/joshtoth/dev/strands-test/.venv/lib/python3.13/site-packages/botocore/eventstream.py", line 608, in _parse_event
    raise EventStreamError(parsed_response, self._operation_name)
botocore.exceptions.EventStreamError: An error occurred (validationException) when calling the ConverseStream operation: The model returned the following errors: tools.0.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12 (https://json-schema.org/draft/2020-12). Learn more about tool use at https://docs.anthropic.com/en/docs/tool-use.

Additional Context

  1. Either change the method to just use a 'str' or change back to version 0.1.6 and it works again.

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions