Skip to content

Commit b61383b

Browse files
fix(integrations): add values for pydantic-ai and openai-agents to _INTEGRATION_DEACTIVATES to prohibit double span creation (#5196)
#### Issues Contributes to: https://linear.app/getsentry/issue/TET-1511/openai-agents-double-span-reporting
1 parent 9a1b1aa commit b61383b

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

sentry_sdk/integrations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def iter_default_integrations(with_auto_enabling_integrations):
176176

177177
_INTEGRATION_DEACTIVATES = {
178178
"langchain": {"openai", "anthropic"},
179+
"openai_agents": {"openai"},
180+
"pydantic_ai": {"openai", "anthropic"},
179181
}
180182

181183

tests/test_ai_integration_deactivation.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,29 @@
2626
has_anthropic = False
2727

2828

29+
try:
30+
from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration
31+
32+
has_openai_agents = True
33+
except Exception:
34+
has_openai_agents = False
35+
36+
try:
37+
from sentry_sdk.integrations.pydantic_ai import PydanticAIIntegration
38+
39+
has_pydantic_ai = True
40+
except Exception:
41+
has_pydantic_ai = False
42+
43+
2944
pytestmark = pytest.mark.skipif(
30-
not (has_langchain and has_openai and has_anthropic),
45+
not (
46+
has_langchain
47+
and has_openai
48+
and has_anthropic
49+
and has_openai_agents
50+
and has_pydantic_ai
51+
),
3152
reason="Requires langchain, openai, and anthropic packages to be installed",
3253
)
3354

@@ -36,6 +57,11 @@ def test_integration_deactivates_map_exists():
3657
assert "langchain" in _INTEGRATION_DEACTIVATES
3758
assert "openai" in _INTEGRATION_DEACTIVATES["langchain"]
3859
assert "anthropic" in _INTEGRATION_DEACTIVATES["langchain"]
60+
assert "openai_agents" in _INTEGRATION_DEACTIVATES
61+
assert "openai" in _INTEGRATION_DEACTIVATES["openai_agents"]
62+
assert "pydantic_ai" in _INTEGRATION_DEACTIVATES
63+
assert "openai" in _INTEGRATION_DEACTIVATES["pydantic_ai"]
64+
assert "anthropic" in _INTEGRATION_DEACTIVATES["pydantic_ai"]
3965

4066

4167
def test_langchain_auto_deactivates_openai_and_anthropic(
@@ -104,13 +130,17 @@ def test_user_can_override_with_both_explicit_integrations(
104130
assert AnthropicIntegration in integration_types
105131

106132

107-
def test_disabling_langchain_allows_openai_and_anthropic(
133+
def test_disabling_integrations_allows_openai_and_anthropic(
108134
sentry_init, reset_integrations
109135
):
110136
sentry_init(
111137
default_integrations=False,
112138
auto_enabling_integrations=True,
113-
disabled_integrations=[LangchainIntegration],
139+
disabled_integrations=[
140+
LangchainIntegration,
141+
OpenAIAgentsIntegration,
142+
PydanticAIIntegration,
143+
],
114144
)
115145

116146
client = get_client()

0 commit comments

Comments
 (0)