diff --git a/src/strands/tools/structured_output.py b/src/strands/tools/structured_output.py index 6f2739d88..c055cf89b 100644 --- a/src/strands/tools/structured_output.py +++ b/src/strands/tools/structured_output.py @@ -275,7 +275,7 @@ def convert_pydantic_to_tool_spec( Returns: ToolSpec: Dict containing the Bedrock tool specification """ - name = model.__name__ + name = f"{model.__name__}OutputStructurer" # Get the JSON schema input_schema = model.model_json_schema() @@ -300,7 +300,7 @@ def convert_pydantic_to_tool_spec( # Construct the tool specification return ToolSpec( name=name, - description=model_description or f"{name} structured output tool", + description=model_description or f"{model.__name__} structured output tool", inputSchema={"json": final_schema}, ) diff --git a/tests/strands/models/test_anthropic.py b/tests/strands/models/test_anthropic.py index 5e8d69ea7..b7236890c 100644 --- a/tests/strands/models/test_anthropic.py +++ b/tests/strands/models/test_anthropic.py @@ -724,7 +724,7 @@ async def test_structured_output(anthropic_client, model, test_output_model_cls, return_value={ "type": "content_block_start", "index": 0, - "content_block": {"type": "tool_use", "id": "123", "name": "TestOutputModel"}, + "content_block": {"type": "tool_use", "id": "123", "name": "TestOutputModelOutputStructurer"}, } ), ), diff --git a/tests/strands/models/test_bedrock.py b/tests/strands/models/test_bedrock.py index 47e028cb9..c45b1b2ca 100644 --- a/tests/strands/models/test_bedrock.py +++ b/tests/strands/models/test_bedrock.py @@ -1084,7 +1084,11 @@ async def test_structured_output(bedrock_client, model, test_output_model_cls, a bedrock_client.converse_stream.return_value = { "stream": [ {"messageStart": {"role": "assistant"}}, - {"contentBlockStart": {"start": {"toolUse": {"toolUseId": "123", "name": "TestOutputModel"}}}}, + { + "contentBlockStart": { + "start": {"toolUse": {"toolUseId": "123", "name": "TestOutputModelOutputStructurer"}} + } + }, {"contentBlockDelta": {"delta": {"toolUse": {"input": '{"name": "John", "age": 30}'}}}}, {"contentBlockStop": {}}, {"messageStop": {"stopReason": "tool_use"}}, diff --git a/tests/strands/tools/test_structured_output.py b/tests/strands/tools/test_structured_output.py index 97b68a34c..e68ae55f9 100644 --- a/tests/strands/tools/test_structured_output.py +++ b/tests/strands/tools/test_structured_output.py @@ -41,7 +41,7 @@ def test_convert_pydantic_to_tool_spec_basic(): tool_spec = convert_pydantic_to_tool_spec(User) expected_spec = { - "name": "User", + "name": "UserOutputStructurer", "description": "User model with name and age.", "inputSchema": { "json": { @@ -73,7 +73,7 @@ def test_convert_pydantic_to_tool_spec_complex(): tool_spec = convert_pydantic_to_tool_spec(ListOfUsersWithPlanet) expected_spec = { - "name": "ListOfUsersWithPlanet", + "name": "ListOfUsersWithPlanetOutputStructurer", "description": "List of users model with planet.", "inputSchema": { "json": { @@ -127,7 +127,7 @@ def test_convert_pydantic_to_tool_spec_multiple_same_type(): tool_spec = convert_pydantic_to_tool_spec(TwoUsersWithPlanet) expected_spec = { - "name": "TwoUsersWithPlanet", + "name": "TwoUsersWithPlanetOutputStructurer", "description": "Two users model with planet.", "inputSchema": { "json": { @@ -286,7 +286,7 @@ class Person(BaseModel): "type": "object", } }, - "name": "Person", + "name": "PersonOutputStructurer", } assert tool_spec == expected_spec @@ -340,6 +340,6 @@ class Person(BaseModel): "type": "object", } }, - "name": "Person", + "name": "PersonOutputStructurer", } assert tool_spec == expected_spec