From 1bb11bc0033142746b0c50d6418bd46faa7c3fd2 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Mon, 5 Oct 2026 09:52:59 +0200 Subject: [PATCH] chore: Replace deprecated gen_ai.tool.output with gen_ai.tool.call.result --- sentry_sdk/integrations/google_genai/utils.py | 4 ++-- sentry_sdk/integrations/langchain.py | 2 +- .../openai_agents/spans/execute_tool.py | 2 +- .../pydantic_ai/spans/execute_tool.py | 2 +- tests/integrations/langchain/test_langchain.py | 14 +++++++------- .../openai_agents/test_openai_agents.py | 15 +++++++++++---- .../integrations/pydantic_ai/test_pydantic_ai.py | 10 +++++----- 7 files changed, 28 insertions(+), 21 deletions(-) diff --git a/sentry_sdk/integrations/google_genai/utils.py b/sentry_sdk/integrations/google_genai/utils.py index 01d7f80dd0..515b0b6e0a 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 b188dc811d..b810b7f02c 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 b4ec65da0f..6a1d2c9a0d 100644 --- a/sentry_sdk/integrations/openai_agents/spans/execute_tool.py +++ b/sentry_sdk/integrations/openai_agents/spans/execute_tool.py @@ -44,7 +44,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 4c64a1dc0d..60b9776827 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 f777d73ef7..a73bd8b1b0 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -1089,7 +1089,7 @@ def test_tool_execution_span_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_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", {} @@ -1265,7 +1265,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 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] @@ -1435,7 +1435,7 @@ 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_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", {} @@ -1660,7 +1660,7 @@ 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_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", {} @@ -1848,7 +1848,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 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] @@ -3359,12 +3359,12 @@ 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_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_INPUT], 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..41aa59d8fe 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -1377,7 +1377,10 @@ async def test_tool_execution_span( 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"]["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" @@ -1580,7 +1583,10 @@ async def test_run_streamed_tool_execution_span( 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"]["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 @@ -1731,10 +1737,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 9c1871790c..d7834851d9 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 "gen_ai.tool.input" 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 "gen_ai.tool.input" 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 "gen_ai.tool.input" 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 "gen_ai.tool.input" 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_INPUT]) expected_tool_return = str(tool_input["a"] + tool_input["b"])