Skip to content

Commit f945e38

Browse files
authored
Fix openai-agents import (#5132)
### Description "agents" is too generic a name, and we're using it to determine whether someone has openai-agents installed. #### Issues Closes #5129 #### Reminders - Please add tests to validate your changes, and lint your code using `tox -e linters`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent 8596f89 commit f945e38

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sentry_sdk/integrations/openai_agents/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
)
1010

1111
try:
12+
# "agents" is too generic. If someone has an agents.py file in their project
13+
# or another package that's importable via "agents", no ImportError would not
14+
# be thrown and the integration would enable itself even if openai-agents is
15+
# not installed. That's why we're adding the second, more specific import
16+
# after it, even if we don't use it.
1217
import agents
18+
from agents.run import DEFAULT_AGENT_RUNNER
1319

1420
except ImportError:
1521
raise DidNotEnable("OpenAI Agents not installed")

0 commit comments

Comments
 (0)