From ab9d10d76de2f0e15e9a53a01e69b2e84e7f7776 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Fri, 6 Mar 2026 10:06:24 +0100 Subject: [PATCH 1/2] test(openai-agents): Add namespace field for new openai versions --- .../openai_agents/test_openai_agents.py | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/integrations/openai_agents/test_openai_agents.py b/tests/integrations/openai_agents/test_openai_agents.py index 491223e804..6edc624247 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -12,7 +12,7 @@ from sentry_sdk.integrations.logging import LoggingIntegration from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration from sentry_sdk.integrations.openai_agents.utils import _set_input_data, safe_serialize -from sentry_sdk.utils import parse_version +from sentry_sdk.utils import parse_version, package_version from openai import AsyncOpenAI from agents.models.openai_responses import OpenAIResponsesModel @@ -37,6 +37,8 @@ from agents.exceptions import MaxTurnsExceeded, ModelBehaviorError from agents.version import __version__ as OPENAI_AGENTS_VERSION +OPENAI_VERSION = package_version("openai") + from openai.types.responses import ( ResponseCreatedEvent, ResponseTextDeltaEvent, @@ -1256,17 +1258,21 @@ def simple_test_tool(message: str) -> str: assert ai_client_span1["data"]["gen_ai.usage.output_tokens"] == 5 assert ai_client_span1["data"]["gen_ai.usage.output_tokens.reasoning"] == 0 assert ai_client_span1["data"]["gen_ai.usage.total_tokens"] == 15 + + tool_call = { + "arguments": '{"message": "hello"}', + "call_id": "call_123", + "name": "simple_test_tool", + "type": "function_call", + "id": "call_123", + "status": None, + } + + if OPENAI_VERSION >= (2, 25, 0): + tool_call["namespace"] = None + assert ai_client_span1["data"]["gen_ai.response.tool_calls"] == safe_serialize( - [ - { - "arguments": '{"message": "hello"}', - "call_id": "call_123", - "name": "simple_test_tool", - "type": "function_call", - "id": "call_123", - "status": None, - } - ] + [tool_call] ) assert tool_span["description"] == "execute_tool simple_test_tool" From 38e71a78d124f35537a99c2b9245da18272abccb Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Fri, 6 Mar 2026 10:10:26 +0100 Subject: [PATCH 2/2] use json loads --- tests/integrations/openai_agents/test_openai_agents.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integrations/openai_agents/test_openai_agents.py b/tests/integrations/openai_agents/test_openai_agents.py index 6edc624247..1390455317 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -1271,9 +1271,9 @@ def simple_test_tool(message: str) -> str: if OPENAI_VERSION >= (2, 25, 0): tool_call["namespace"] = None - assert ai_client_span1["data"]["gen_ai.response.tool_calls"] == safe_serialize( - [tool_call] - ) + assert json.loads(ai_client_span1["data"]["gen_ai.response.tool_calls"]) == [ + tool_call + ] assert tool_span["description"] == "execute_tool simple_test_tool" assert tool_span["data"]["gen_ai.agent.name"] == "test_agent"