Skip to content

OpenAI Agents integration crashes on startup with openai-agents >= 0.7.0 (AttributeError: AgentRunner._get_all_tools) #5433

@mrporsev

Description

@mrporsev

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.51.0

Steps to Reproduce

  1. Install sentry-sdk[fastapi]==2.51.0 and openai-agents==0.8.0
  2. Initialize Sentry with default auto-enabled integrations:
    import sentry_sdk

sentry_sdk.init(
dsn="...",
send_default_pii=True,
traces_sample_rate=1.0,
)
3. The app crashes immediately on startup before serving any
requests.

Expected Result

Sentry initializes successfully. The openai_agents integration either works with openai-agents>=0.7.0 or gracefully skips itself if the installed version is incompatible.

Actual Result

File "/usr/local/lib/python3.11/site-packages/sentry_sdk/client.py",
  line 423, in _init_impl
      self.integrations = setup_integrations(
                          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations
  /__init__.py", line 258, in setup_integrations
      type(integration).setup_once()
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations
  /openai_agents/__init__.py", line 60, in setup_once
      _patch_tools()
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations
  /openai_agents/__init__.py", line 50, in _patch_tools

  _create_get_all_tools_wrapper(agents.run.AgentRunner._get_all_tools),

  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  AttributeError: type object 'AgentRunner' has no attribute
  '_get_all_tools'

The openai_agents integration auto-enables when openai-agents is
installed and tries to monkey-patch AgentRunner._get_all_tools, which
was removed in openai-agents ~0.7.0 (see
openai/openai-agents-python#1267). Since the
integration doesn't check the library version, it crashes the entire
application on startup with no way to recover, the exception is
unhandled during sentry_sdk.init().

This is particularly severe because it's a hard crash (not a warning)
and prevents the application from starting at all.

Metadata

Metadata

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions