File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed
tests/integrations/anthropic Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change 1313 truncate_and_annotate_messages ,
1414 get_start_span_function ,
1515 transform_anthropic_content_part ,
16- _normalize_data ,
1716)
1817from sentry_sdk .consts import OP , SPANDATA , SPANSTATUS
1918from sentry_sdk .integrations import _check_minimum_version , DidNotEnable , Integration
@@ -379,13 +378,16 @@ def _transform_anthropic_tools(
379378
380379 transformed_tool = {
381380 "name" : tool .get ("name" ),
382- "description" : tool .get ("description" ),
383381 "type" : "function" ,
384382 }
385383
384+ description = tool .get ("description" )
385+ if description is not None :
386+ transformed_tool ["description" ] = description
387+
386388 input_schema = tool .get ("input_schema" )
387- if input_schema :
388- transformed_tool ["parameters" ] = _normalize_data ( input_schema , unpack = False )
389+ if input_schema is not None :
390+ transformed_tool ["parameters" ] = input_schema
389391
390392 transformed_tools .append (transformed_tool )
391393
Original file line number Diff line number Diff line change 4141 },
4242 "required" : ["location" ],
4343 },
44- }
44+ },
45+ {
46+ "name" : "no_description_tool" ,
47+ "input_schema" : {
48+ "type" : "object" ,
49+ "properties" : {"arg1" : {"type" : "string" }},
50+ },
51+ },
4552]
4653
4754
@@ -96,13 +103,21 @@ def test_tool_definitions_in_create_message(
96103 if send_default_pii and include_prompts :
97104 assert SPANDATA .GEN_AI_TOOL_DEFINITIONS in span ["data" ]
98105 tool_definitions = json .loads (span ["data" ][SPANDATA .GEN_AI_TOOL_DEFINITIONS ])
99- assert len (tool_definitions ) == 1
106+ assert len (tool_definitions ) == 2
107+
108+ # Check tool with description
100109 assert tool_definitions [0 ]["name" ] == "get_weather"
101110 assert (
102111 tool_definitions [0 ]["description" ]
103112 == "Get the current weather in a given location"
104113 )
105114 assert tool_definitions [0 ]["type" ] == "function"
106115 assert tool_definitions [0 ]["parameters" ] == TOOLS [0 ]["input_schema" ]
116+
117+ # Check tool without description
118+ assert tool_definitions [1 ]["name" ] == "no_description_tool"
119+ assert "description" not in tool_definitions [1 ]
120+ assert tool_definitions [1 ]["type" ] == "function"
121+ assert tool_definitions [1 ]["parameters" ] == TOOLS [1 ]["input_schema" ]
107122 else :
108123 assert SPANDATA .GEN_AI_TOOL_DEFINITIONS not in span ["data" ]
You can’t perform that action at this time.
0 commit comments