diff --git a/sentry_sdk/integrations/openai_agents/__init__.py b/sentry_sdk/integrations/openai_agents/__init__.py index 7e2dee0f66..1f138b5e65 100644 --- a/sentry_sdk/integrations/openai_agents/__init__.py +++ b/sentry_sdk/integrations/openai_agents/__init__.py @@ -9,7 +9,13 @@ ) try: + # "agents" is too generic. If someone has an agents.py file in their project + # or another package that's importable via "agents", no ImportError would not + # be thrown and the integration would enable itself even if openai-agents is + # not installed. That's why we're adding the second, more specific import + # after it, even if we don't use it. import agents + from agents.run import DEFAULT_AGENT_RUNNER except ImportError: raise DidNotEnable("OpenAI Agents not installed")