Skip to content

Support openai-agents #4437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 77 commits into
base: master
Choose a base branch
from

Conversation

antonpirker
Copy link
Member

@antonpirker antonpirker commented Jun 3, 2025

Add support for AI agents projects using openai-agents (https://pypi.org/project/openai-agents/)

This integration:

  • records tracing data of agent invocation, tool execution, requests to LLMs
  • is mostly compatible to the OpenTelememetry gen_ai semantic conventions. (input and output is not compatible because Sentry does not have Span events. This information is stored in arrays on the Span attributes.
  • Captures errors that happen during agent execution (like problems during interaction with the LLM.

This integration does not:

  • Capture errors during function tool exection because this is very hard to patch (see comment in the code)

Copy link

codecov bot commented Jun 3, 2025

❌ 5 Tests Failed:

Tests completed Failed Passed Skipped
24101 5 24096 5807
View the top 3 failed test(s) by shortest run time
::tests.integrations.sanic.test_sanic
Stack Traces | 0s run time
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/_pytest/python.py:498: in importtestmodule
    mod = import_path(
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/_pytest/pathlib.py:587: in import_path
    importlib.import_module(module_name)
.../hostedtoolcache/Python/3.12.10.../x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1310: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:488: in _call_with_frames_removed
    ???
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:999: in exec_module
    ???
<frozen importlib._bootstrap>:488: in _call_with_frames_removed
    ???
.../integrations/sanic/__init__.py:3: in <module>
    pytest.importorskip("sanic")
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/sanic/__init__.py:6: in <module>
    from sanic.app import Sanic
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/sanic/app.py:58: in <module>
    from sanic.application.state import ApplicationState, ServerStage
.tox/py3.12-sanic-v24.6/lib/python3.12.../sanic/application/state.py:13: in <module>
    from sanic.server.async_server import AsyncioServer
.tox/py3.12-sanic-v24.6/lib/python3.12.../sanic/server/__init__.py:5: in <module>
    from sanic.server.runners import serve
.tox/py3.12-sanic-v24.6/lib/python3.12.../sanic/server/runners.py:6: in <module>
    from sanic.config import Config
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/sanic/config.py:13: in <module>
    from sanic.errorpages import DEFAULT_FORMAT, check_error_format
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/sanic/errorpages.py:27: in <module>
    from sanic.pages.error import ErrorPage
.tox/py3.12-sanic-v24.6/lib/python3.12.../sanic/pages/error.py:3: in <module>
    import tracerite.html
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/tracerite/__init__.py:1: in <module>
    from .html import html_traceback
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/tracerite/html.py:3: in <module>
    from .trace import extract_chain
.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/tracerite/trace.py:11: in <module>
    from .inspector import extract_variables
E     File ".../sentry-python/sentry-python/.tox/py3.12-sanic-v24.6/lib/python3.12.../site-packages/tracerite/inspector.py", line 119
E       except AttributeError, TypeError:
E              ^^^^^^^^^^^^^^^^^^^^^^^^^
E   SyntaxError: multiple exception types must be parenthesized
::tests.integrations.sanic.test_sanic
Stack Traces | 0s run time
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/_pytest/python.py:498: in importtestmodule
    mod = import_path(
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/_pytest/pathlib.py:587: in import_path
    importlib.import_module(module_name)
.../hostedtoolcache/Python/3.13.3.../x64/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1310: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:488: in _call_with_frames_removed
    ???
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:1026: in exec_module
    ???
<frozen importlib._bootstrap>:488: in _call_with_frames_removed
    ???
.../integrations/sanic/__init__.py:3: in <module>
    pytest.importorskip("sanic")
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/sanic/__init__.py:6: in <module>
    from sanic.app import Sanic
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/sanic/app.py:50: in <module>
    from sanic.application.state import ApplicationState, ServerStage
.tox/py3.13-sanic-latest/lib/python3.13.../sanic/application/state.py:13: in <module>
    from sanic.server.async_server import AsyncioServer
.tox/py3.13-sanic-latest/lib/python3.13.../sanic/server/__init__.py:5: in <module>
    from sanic.server.runners import serve
.tox/py3.13-sanic-latest/lib/python3.13.../sanic/server/runners.py:6: in <module>
    from sanic.config import Config
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/sanic/config.py:12: in <module>
    from sanic.errorpages import DEFAULT_FORMAT, check_error_format
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/sanic/errorpages.py:27: in <module>
    from sanic.pages.error import ErrorPage
.tox/py3.13-sanic-latest/lib/python3.13.../sanic/pages/error.py:4: in <module>
    import tracerite.html
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/tracerite/__init__.py:1: in <module>
    from .html import html_traceback
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/tracerite/html.py:3: in <module>
    from .trace import extract_chain
.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/tracerite/trace.py:11: in <module>
    from .inspector import extract_variables
E     File ".../sentry-python/sentry-python/.tox/py3.13-sanic-latest/lib/python3.13.../site-packages/tracerite/inspector.py", line 119
E       except AttributeError, TypeError:
E              ^^^^^^^^^^^^^^^^^^^^^^^^^
E   SyntaxError: multiple exception types must be parenthesized
::tests.integrations.sanic.test_sanic
Stack Traces | 0s run time
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/_pytest/python.py:498: in importtestmodule
    mod = import_path(
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/_pytest/pathlib.py:587: in import_path
    importlib.import_module(module_name)
.../hostedtoolcache/Python/3.11.12.../x64/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1126: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:940: in exec_module
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
.../integrations/sanic/__init__.py:3: in <module>
    pytest.importorskip("sanic")
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/sanic/__init__.py:6: in <module>
    from sanic.app import Sanic
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/sanic/app.py:58: in <module>
    from sanic.application.state import ApplicationState, ServerStage
.tox/py3.11-sanic-v24.6/lib/python3.11.../sanic/application/state.py:13: in <module>
    from sanic.server.async_server import AsyncioServer
.tox/py3.11-sanic-v24.6/lib/python3.11.../sanic/server/__init__.py:5: in <module>
    from sanic.server.runners import serve
.tox/py3.11-sanic-v24.6/lib/python3.11.../sanic/server/runners.py:6: in <module>
    from sanic.config import Config
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/sanic/config.py:13: in <module>
    from sanic.errorpages import DEFAULT_FORMAT, check_error_format
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/sanic/errorpages.py:27: in <module>
    from sanic.pages.error import ErrorPage
.tox/py3.11-sanic-v24.6/lib/python3.11.../sanic/pages/error.py:3: in <module>
    import tracerite.html
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/tracerite/__init__.py:1: in <module>
    from .html import html_traceback
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/tracerite/html.py:3: in <module>
    from .trace import extract_chain
.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/tracerite/trace.py:11: in <module>
    from .inspector import extract_variables
E     File ".../sentry-python/sentry-python/.tox/py3.11-sanic-v24.6/lib/python3.11.../site-packages/tracerite/inspector.py", line 119
E       except AttributeError, TypeError:
E              ^^^^^^^^^^^^^^^^^^^^^^^^^
E   SyntaxError: multiple exception types must be parenthesized

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant