diff --git a/sentry_sdk/integrations/google_genai/utils.py b/sentry_sdk/integrations/google_genai/utils.py index 01d7f80dd0..eeb6d5f5cd 100644 --- a/sentry_sdk/integrations/google_genai/utils.py +++ b/sentry_sdk/integrations/google_genai/utils.py @@ -710,7 +710,7 @@ async def async_wrapped(*args: "Any", **kwargs: "Any") -> "Any": tool_input = _capture_tool_input(args, kwargs, tool) with capture_internal_exceptions(): span.set_attribute( - SPANDATA.GEN_AI_TOOL_INPUT, safe_serialize(tool_input) + SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, safe_serialize(tool_input) ) try: @@ -737,7 +737,7 @@ def sync_wrapped(*args: "Any", **kwargs: "Any") -> "Any": tool_input = _capture_tool_input(args, kwargs, tool) with capture_internal_exceptions(): span.set_attribute( - SPANDATA.GEN_AI_TOOL_INPUT, safe_serialize(tool_input) + SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, safe_serialize(tool_input) ) try: diff --git a/sentry_sdk/integrations/langchain.py b/sentry_sdk/integrations/langchain.py index b188dc811d..b995b14a52 100644 --- a/sentry_sdk/integrations/langchain.py +++ b/sentry_sdk/integrations/langchain.py @@ -735,7 +735,7 @@ def on_tool_start( set_data_normalized( span, - SPANDATA.GEN_AI_TOOL_INPUT, + SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, kwargs.get("inputs", [input_str]), ) diff --git a/sentry_sdk/integrations/openai_agents/patches/runner.py b/sentry_sdk/integrations/openai_agents/patches/runner.py index 363fc20b4c..f8c84ab6b6 100644 --- a/sentry_sdk/integrations/openai_agents/patches/runner.py +++ b/sentry_sdk/integrations/openai_agents/patches/runner.py @@ -57,7 +57,7 @@ async def on_tool_start( if not client.options["data_collection"]["gen_ai"]["inputs"]: return - span.set_attribute(SPANDATA.GEN_AI_TOOL_INPUT, context.tool_arguments) + span.set_attribute(SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, context.tool_arguments) async def on_tool_end( self, diff --git a/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py b/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py index 4c64a1dc0d..4c31702dec 100644 --- a/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py +++ b/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py @@ -53,7 +53,7 @@ def execute_tool_span( ): return span - span.set_attribute(SPANDATA.GEN_AI_TOOL_INPUT, safe_serialize(tool_args)) + span.set_attribute(SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, safe_serialize(tool_args)) return span diff --git a/tests/integrations/langchain/test_langchain.py b/tests/integrations/langchain/test_langchain.py index f777d73ef7..3129c9ffd2 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -913,7 +913,7 @@ def test_tool_execution_span( chat_spans[1]["attributes"][SPANDATA.GEN_AI_RESPONSE_MODEL] == "gpt-4-0613" ) - assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_INPUT] + assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS] assert "5" in chat_spans[1]["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT] @@ -1088,7 +1088,9 @@ def test_tool_execution_span_no_sensitive_data( assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[0].get("attributes", {}) assert SPANDATA.GEN_AI_REQUEST_MESSAGES not in chat_spans[1].get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[1].get("attributes", {}) - assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_exec_span.get("attributes", {}) + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_exec_span.get( + "attributes", {} + ) assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_exec_span.get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get( @@ -1264,7 +1266,7 @@ def test_langchain_openai_tools_agent( ) assert "5" in chat_spans[0]["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT] - assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_INPUT] + assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS] assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_OUTPUT]) assert json.loads( @@ -1434,7 +1436,9 @@ def test_langchain_openai_tools_agent_no_sensitive_data( ) assert SPANDATA.GEN_AI_REQUEST_MESSAGES not in chat_spans[1].get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[1].get("attributes", {}) - assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_exec_span.get("attributes", {}) + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_exec_span.get( + "attributes", {} + ) assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_exec_span.get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get( @@ -1659,7 +1663,9 @@ def test_langchain_openai_tools_agent_stream_no_sensitive_data( ) assert SPANDATA.GEN_AI_REQUEST_MESSAGES not in chat_spans[1].get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[1].get("attributes", {}) - assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_exec_span.get("attributes", {}) + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_exec_span.get( + "attributes", {} + ) assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_exec_span.get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get( @@ -1847,7 +1853,7 @@ def test_langchain_openai_tools_agent_stream( ) assert "5" in chat_spans[0]["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT] - assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_INPUT] + assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS] assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_OUTPUT]) assert json.loads( @@ -3358,14 +3364,14 @@ def test_langchain_data_collection_request_tool_call_params( [ pytest.param( {"gen_ai": {"inputs": True, "outputs": False}}, - {SPANDATA.GEN_AI_TOOL_INPUT: {"word": "eudca"}}, + {SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS: {"word": "eudca"}}, [SPANDATA.GEN_AI_TOOL_OUTPUT], id="gen-ai-inputs-enabled-outputs-disabled", ), pytest.param( {"gen_ai": {"inputs": False, "outputs": True}}, {SPANDATA.GEN_AI_TOOL_OUTPUT: 5}, - [SPANDATA.GEN_AI_TOOL_INPUT], + [SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS], id="gen-ai-outputs-enabled-inputs-disabled", ), ], diff --git a/tests/integrations/openai_agents/test_openai_agents.py b/tests/integrations/openai_agents/test_openai_agents.py index 4b3048dc3d..fb98e68c79 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -1375,7 +1375,10 @@ async def test_tool_execution_span( assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0 assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool" - assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}' + assert ( + tool_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS] + == '{"message": "hello"}' + ) assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool" assert tool_span["attributes"]["gen_ai.tool.output"] == "Tool executed with: hello" assert ai_client_span2["name"] == "chat gpt-4" @@ -1578,7 +1581,10 @@ async def test_run_streamed_tool_execution_span( assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0 assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai" assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool" - assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}' + assert ( + tool_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS] + == '{"message": "hello"}' + ) assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool" assert tool_span["attributes"]["gen_ai.tool.output"] == "Tool executed with: hello" @@ -1725,9 +1731,12 @@ async def test_tool_execution_span_data_collection( ) if expect_input: - assert tool_span_data[SPANDATA.GEN_AI_TOOL_INPUT] == '{"message": "hello"}' + assert ( + tool_span_data[SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS] + == '{"message": "hello"}' + ) else: - assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_span_data + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_span_data if expect_output: assert ( diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index 9c1871790c..e0eeaeec92 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -419,7 +419,7 @@ def add_numbers(a: int, b: int) -> int: assert "execute_tool" in tool_span["name"] assert tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool" assert tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers" - assert "gen_ai.tool.input" in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"] assert "gen_ai.tool.output" in tool_span["attributes"] # Check chat spans have available_tools @@ -505,13 +505,13 @@ def add_numbers(a: int, b: int) -> float: model_retry_tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool" ) assert model_retry_tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers" - assert "gen_ai.tool.input" in model_retry_tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in model_retry_tool_span["attributes"] tool_span = tool_spans[1] assert "execute_tool" in tool_span["name"] assert tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool" assert tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers" - assert "gen_ai.tool.input" in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"] assert "gen_ai.tool.output" in tool_span["attributes"] # Check chat spans have available_tools @@ -636,7 +636,7 @@ def multiply(a: int, b: int) -> int: # Check tool span tool_span = tool_spans[0] assert tool_span["attributes"]["gen_ai.tool.name"] == "multiply" - assert "gen_ai.tool.input" in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"] assert "gen_ai.tool.output" in tool_span["attributes"] @@ -873,7 +873,7 @@ def sensitive_tool(data: str) -> str: # If tool was executed, verify input/output are not captured for tool_span in tool_spans: - assert "gen_ai.tool.input" not in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_span["attributes"] assert "gen_ai.tool.output" not in tool_span["attributes"] @@ -3080,7 +3080,7 @@ def add_numbers(a: int, b: int) -> int: # sent, so the assertion does not depend on the test model's defaults. tool_span = tool_spans[0] assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_span - tool_input = json.loads(tool_span[SPANDATA.GEN_AI_TOOL_INPUT]) + tool_input = json.loads(tool_span[SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]) expected_tool_return = str(tool_input["a"] + tool_input["b"]) tool_messages = [