diff --git a/sentry_sdk/integrations/google_genai/utils.py b/sentry_sdk/integrations/google_genai/utils.py index eeb6d5f5cd..560b3748c7 100644 --- a/sentry_sdk/integrations/google_genai/utils.py +++ b/sentry_sdk/integrations/google_genai/utils.py @@ -719,7 +719,7 @@ async def async_wrapped(*args: "Any", **kwargs: "Any") -> "Any": # Capture tool output with capture_internal_exceptions(): span.set_attribute( - SPANDATA.GEN_AI_TOOL_OUTPUT, safe_serialize(result) + SPANDATA.GEN_AI_TOOL_CALL_RESULT, safe_serialize(result) ) return result @@ -746,7 +746,7 @@ def sync_wrapped(*args: "Any", **kwargs: "Any") -> "Any": # Capture tool output with capture_internal_exceptions(): span.set_attribute( - SPANDATA.GEN_AI_TOOL_OUTPUT, safe_serialize(result) + SPANDATA.GEN_AI_TOOL_CALL_RESULT, safe_serialize(result) ) return result diff --git a/sentry_sdk/integrations/langchain.py b/sentry_sdk/integrations/langchain.py index b995b14a52..486d554a7b 100644 --- a/sentry_sdk/integrations/langchain.py +++ b/sentry_sdk/integrations/langchain.py @@ -755,7 +755,7 @@ def on_tool_end( ) if sentry_sdk.get_client().options["data_collection"]["gen_ai"]["outputs"]: - set_data_normalized(span, SPANDATA.GEN_AI_TOOL_OUTPUT, output) + set_data_normalized(span, SPANDATA.GEN_AI_TOOL_CALL_RESULT, output) self._exit_span(span, run_id) diff --git a/sentry_sdk/integrations/openai_agents/spans/execute_tool.py b/sentry_sdk/integrations/openai_agents/spans/execute_tool.py index c89ab27abd..4104f602fe 100644 --- a/sentry_sdk/integrations/openai_agents/spans/execute_tool.py +++ b/sentry_sdk/integrations/openai_agents/spans/execute_tool.py @@ -43,7 +43,7 @@ def update_execute_tool_span( span.status = SpanStatus.ERROR if client.options["data_collection"]["gen_ai"]["outputs"]: - span.set_attribute(SPANDATA.GEN_AI_TOOL_OUTPUT, result) + span.set_attribute(SPANDATA.GEN_AI_TOOL_CALL_RESULT, result) # Add conversation ID from agent conv_id = getattr(agent, "_sentry_conversation_id", None) diff --git a/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py b/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py index 4c31702dec..13583cdb23 100644 --- a/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py +++ b/sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py @@ -69,4 +69,4 @@ def update_execute_tool_span(span: "Span", result: "Any") -> None: ): return - span.set_attribute(SPANDATA.GEN_AI_TOOL_OUTPUT, safe_serialize(result)) + span.set_attribute(SPANDATA.GEN_AI_TOOL_CALL_RESULT, safe_serialize(result)) diff --git a/tests/integrations/langchain/test_langchain.py b/tests/integrations/langchain/test_langchain.py index 3129c9ffd2..08e502a0ab 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -1091,7 +1091,7 @@ def test_tool_execution_span_no_sensitive_data( 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_TOOL_CALL_RESULT not in tool_exec_span.get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get( "attributes", {} @@ -1267,7 +1267,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_CALL_ARGUMENTS] - assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_OUTPUT]) + assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_RESULT]) assert json.loads( chat_spans[0]["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES] @@ -1439,7 +1439,7 @@ def test_langchain_openai_tools_agent_no_sensitive_data( 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_TOOL_CALL_RESULT not in tool_exec_span.get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get( "attributes", {} @@ -1666,7 +1666,7 @@ def test_langchain_openai_tools_agent_stream_no_sensitive_data( 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_TOOL_CALL_RESULT not in tool_exec_span.get("attributes", {}) assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get( "attributes", {} @@ -1854,7 +1854,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_CALL_ARGUMENTS] - assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_OUTPUT]) + assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_RESULT]) assert json.loads( chat_spans[0]["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES] @@ -3365,12 +3365,12 @@ def test_langchain_data_collection_request_tool_call_params( pytest.param( {"gen_ai": {"inputs": True, "outputs": False}}, {SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS: {"word": "eudca"}}, - [SPANDATA.GEN_AI_TOOL_OUTPUT], + [SPANDATA.GEN_AI_TOOL_CALL_RESULT], 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_CALL_RESULT: 5}, [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 6eb06127a1..4aaa4aa97d 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -1349,7 +1349,10 @@ async def test_tool_execution_span( == '{"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 ( + tool_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_RESULT] + == "Tool executed with: hello" + ) assert ai_client_span2["name"] == "chat gpt-4" assert ai_client_span2["attributes"]["gen_ai.agent.name"] == "test_agent" assert ai_client_span2["attributes"]["gen_ai.operation.name"] == "chat" @@ -1544,7 +1547,10 @@ async def test_run_streamed_tool_execution_span( == '{"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 ( + tool_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_RESULT] + == "Tool executed with: hello" + ) @pytest.fixture @@ -1698,10 +1704,11 @@ async def test_tool_execution_span_data_collection( if expect_output: assert ( - tool_span_data[SPANDATA.GEN_AI_TOOL_OUTPUT] == "Tool executed with: hello" + tool_span_data[SPANDATA.GEN_AI_TOOL_CALL_RESULT] + == "Tool executed with: hello" ) else: - assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_span_data + assert SPANDATA.GEN_AI_TOOL_CALL_RESULT not in tool_span_data @pytest.mark.asyncio diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index 631db40145..ad8de33f1b 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -420,7 +420,7 @@ def add_numbers(a: int, b: int) -> int: assert tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool" assert tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers" assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"] - assert "gen_ai.tool.output" in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_RESULT in tool_span["attributes"] # Check chat spans have available_tools for chat_span in chat_spans: @@ -512,7 +512,7 @@ def add_numbers(a: int, b: int) -> float: assert tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool" assert tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers" assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"] - assert "gen_ai.tool.output" in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_RESULT in tool_span["attributes"] # Check chat spans have available_tools for chat_span in chat_spans: @@ -637,7 +637,7 @@ def multiply(a: int, b: int) -> int: tool_span = tool_spans[0] assert tool_span["attributes"]["gen_ai.tool.name"] == "multiply" assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"] - assert "gen_ai.tool.output" in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_RESULT in tool_span["attributes"] @pytest.mark.asyncio @@ -874,7 +874,7 @@ def sensitive_tool(data: str) -> str: # If tool was executed, verify input/output are not captured for tool_span in tool_spans: assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_span["attributes"] - assert "gen_ai.tool.output" not in tool_span["attributes"] + assert SPANDATA.GEN_AI_TOOL_CALL_RESULT not in tool_span["attributes"] @pytest.mark.asyncio @@ -3079,7 +3079,7 @@ def add_numbers(a: int, b: int) -> int: # Derive the expected return value from the arguments the model actually # 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 + assert SPANDATA.GEN_AI_TOOL_CALL_RESULT not in tool_span tool_input = json.loads(tool_span[SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]) expected_tool_return = str(tool_input["a"] + tool_input["b"])