@@ -2361,7 +2361,6 @@ async def test_execute_tool_span_creation(sentry_init, capture_events):
23612361 """
23622362 import sentry_sdk
23632363 from sentry_sdk .integrations .pydantic_ai .spans .execute_tool import (
2364- execute_tool_span ,
23652364 update_execute_tool_span ,
23662365 )
23672366
@@ -2387,7 +2386,6 @@ async def test_execute_tool_span_with_mcp_type(sentry_init, capture_events):
23872386 Test execute_tool span with MCP tool type.
23882387 """
23892388 import sentry_sdk
2390- from sentry_sdk .integrations .pydantic_ai .spans .execute_tool import execute_tool_span
23912389
23922390 sentry_init (
23932391 integrations = [PydanticAIIntegration ()],
@@ -2412,7 +2410,6 @@ async def test_execute_tool_span_without_prompts(sentry_init, capture_events):
24122410 """
24132411 import sentry_sdk
24142412 from sentry_sdk .integrations .pydantic_ai .spans .execute_tool import (
2415- execute_tool_span ,
24162413 update_execute_tool_span ,
24172414 )
24182415
@@ -2438,7 +2435,6 @@ async def test_execute_tool_span_with_none_args(sentry_init, capture_events):
24382435 Test execute_tool span with None args.
24392436 """
24402437 import sentry_sdk
2441- from sentry_sdk .integrations .pydantic_ai .spans .execute_tool import execute_tool_span
24422438
24432439 sentry_init (
24442440 integrations = [PydanticAIIntegration ()],
@@ -2483,7 +2479,6 @@ async def test_update_execute_tool_span_with_none_result(sentry_init, capture_ev
24832479 """
24842480 import sentry_sdk
24852481 from sentry_sdk .integrations .pydantic_ai .spans .execute_tool import (
2486- execute_tool_span ,
24872482 update_execute_tool_span ,
24882483 )
24892484
@@ -2874,64 +2869,3 @@ def no_docs_tool(a: int, b: int) -> int:
28742869 assert tool_span ["data" ]["gen_ai.tool.name" ] == "no_docs_tool"
28752870 assert SPANDATA .GEN_AI_TOOL_DESCRIPTION in tool_span ["data" ]
28762871 assert tool_span ["data" ][SPANDATA .GEN_AI_TOOL_DESCRIPTION ] is None
2877-
2878-
2879- @pytest .mark .asyncio
2880- async def test_execute_tool_span_with_tool_definition (sentry_init , capture_events ):
2881- """
2882- Test execute_tool_span helper correctly sets tool description from a ToolDefinition.
2883- """
2884-
2885- sentry_init (
2886- integrations = [PydanticAIIntegration ()],
2887- traces_sample_rate = 1.0 ,
2888- send_default_pii = True ,
2889- )
2890-
2891- events = capture_events ()
2892-
2893- tool_def = ToolDefinition (
2894- name = "my_tool" ,
2895- description = "A tool that does something useful." ,
2896- parameters_json_schema = {"type" : "object" , "properties" : {}},
2897- )
2898-
2899- with sentry_sdk .start_transaction (op = "test" , name = "test" ):
2900- with execute_tool_span (
2901- "my_tool" , {"arg" : "value" }, None , "function" , tool_definition = tool_def
2902- ) as span :
2903- assert span is not None
2904-
2905- (event ,) = events
2906- tool_spans = [s for s in event ["spans" ] if s ["op" ] == "gen_ai.execute_tool" ]
2907- assert len (tool_spans ) == 1
2908- assert (
2909- tool_spans [0 ]["data" ][SPANDATA .GEN_AI_TOOL_DESCRIPTION ]
2910- == "A tool that does something useful."
2911- )
2912-
2913-
2914- @pytest .mark .asyncio
2915- async def test_execute_tool_span_without_tool_definition (sentry_init , capture_events ):
2916- """
2917- Test execute_tool_span helper omits tool description when tool_definition is None.
2918- """
2919-
2920- sentry_init (
2921- integrations = [PydanticAIIntegration ()],
2922- traces_sample_rate = 1.0 ,
2923- send_default_pii = True ,
2924- )
2925-
2926- events = capture_events ()
2927-
2928- with sentry_sdk .start_transaction (op = "test" , name = "test" ):
2929- with execute_tool_span (
2930- "my_tool" , {"arg" : "value" }, None , "function" , tool_definition = None
2931- ) as span :
2932- assert span is not None
2933-
2934- (event ,) = events
2935- tool_spans = [s for s in event ["spans" ] if s ["op" ] == "gen_ai.execute_tool" ]
2936- assert len (tool_spans ) == 1
2937- assert SPANDATA .GEN_AI_TOOL_DESCRIPTION not in tool_spans [0 ]["data" ]
0 commit comments