Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def iter_default_integrations(with_auto_enabling_integrations):

_INTEGRATION_DEACTIVATES = {
"langchain": {"openai", "anthropic"},
"openai_agents": {"openai"},
"pydantic_ai": {"openai", "anthropic"},
}


Expand Down
36 changes: 33 additions & 3 deletions tests/test_ai_integration_deactivation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,29 @@
has_anthropic = False


try:
from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration

has_openai_agents = True
except Exception:
has_openai_agents = False

try:
from sentry_sdk.integrations.pydantic_ai import PydanticAIIntegration

has_pydantic_ai = True
except Exception:
has_pydantic_ai = False


pytestmark = pytest.mark.skipif(
not (has_langchain and has_openai and has_anthropic),
not (
has_langchain
and has_openai
and has_anthropic
and has_openai_agents
and has_pydantic_ai
),
reason="Requires langchain, openai, and anthropic packages to be installed",
)

Expand All @@ -36,6 +57,11 @@ def test_integration_deactivates_map_exists():
assert "langchain" in _INTEGRATION_DEACTIVATES
assert "openai" in _INTEGRATION_DEACTIVATES["langchain"]
assert "anthropic" in _INTEGRATION_DEACTIVATES["langchain"]
assert "openai_agents" in _INTEGRATION_DEACTIVATES
assert "openai" in _INTEGRATION_DEACTIVATES["openai_agents"]
assert "pydantic_ai" in _INTEGRATION_DEACTIVATES
assert "openai" in _INTEGRATION_DEACTIVATES["pydantic_ai"]
assert "anthropic" in _INTEGRATION_DEACTIVATES["pydantic_ai"]


def test_langchain_auto_deactivates_openai_and_anthropic(
Expand Down Expand Up @@ -104,13 +130,17 @@ def test_user_can_override_with_both_explicit_integrations(
assert AnthropicIntegration in integration_types


def test_disabling_langchain_allows_openai_and_anthropic(
def test_disabling_integrations_allows_openai_and_anthropic(
sentry_init, reset_integrations
):
sentry_init(
default_integrations=False,
auto_enabling_integrations=True,
disabled_integrations=[LangchainIntegration],
disabled_integrations=[
LangchainIntegration,
OpenAIAgentsIntegration,
PydanticAIIntegration,
],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test doesn't verify OpenAI/Anthropic integrations are enabled

The test test_disabling_integrations_allows_openai_and_anthropic was expanded to disable OpenAIAgentsIntegration and PydanticAIIntegration in addition to LangchainIntegration, but the assertion still only verifies that LangchainIntegration not in integration_types. The test name implies it verifies that OpenAIIntegration and AnthropicIntegration are allowed to be enabled, but there's no assertion checking that they actually are in integration_types.

Fix in Cursor Fix in Web

)

client = get_client()
Expand Down