Skip to content

Commit 4a0e5ed

Browse files
Support openai-agents (#4437)
Add support for AI agents projects using `openai-agents` (https://pypi.org/project/openai-agents/) Docs PR is here: getsentry/sentry-docs#14113 This integration: - records tracing data of agent invocation, tool execution, ai client requests to LLMs, and handoffs to other agents. - captures input and output to/from LLMs if `set_default_pii=True`. - 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) Example span tree in Sentry.io: ![Screenshot 2025-06-24 at 12 15 17](https://github.com/user-attachments/assets/87199067-434f-4bb9-b563-5c6fc18c56cb) --------- Co-authored-by: Ivana Kellyer <[email protected]>
1 parent 7f507fd commit 4a0e5ed

File tree

24 files changed

+1638
-134
lines changed

24 files changed

+1638
-134
lines changed

.github/workflows/test-integrations-ai.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
run: |
6767
set -x # print commands that are executed
6868
./scripts/runtox.sh "py${{ matrix.python-version }}-openai-latest"
69+
- name: Test openai_agents latest
70+
run: |
71+
set -x # print commands that are executed
72+
./scripts/runtox.sh "py${{ matrix.python-version }}-openai_agents-latest"
6973
- name: Test huggingface_hub latest
7074
run: |
7175
set -x # print commands that are executed
@@ -141,6 +145,10 @@ jobs:
141145
run: |
142146
set -x # print commands that are executed
143147
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-openai"
148+
- name: Test openai_agents pinned
149+
run: |
150+
set -x # print commands that are executed
151+
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-openai_agents"
144152
- name: Test huggingface_hub pinned
145153
run: |
146154
set -x # print commands that are executed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ ignore_missing_imports = true
183183
module = "grpc.*"
184184
ignore_missing_imports = true
185185

186+
[[tool.mypy.overrides]]
187+
module = "agents.*"
188+
ignore_missing_imports = true
189+
186190
#
187191
# Tool: Flake8
188192
#

scripts/populate_tox/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@
139139
"loguru": {
140140
"package": "loguru",
141141
},
142+
"openai_agents": {
143+
"package": "openai-agents",
144+
"deps": {
145+
"*": ["pytest-asyncio"],
146+
},
147+
},
142148
"openfeature": {
143149
"package": "openfeature-sdk",
144150
},

scripts/populate_tox/tox.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ setenv =
400400
litestar: TESTPATH=tests/integrations/litestar
401401
loguru: TESTPATH=tests/integrations/loguru
402402
openai: TESTPATH=tests/integrations/openai
403+
openai_agents: TESTPATH=tests/integrations/openai_agents
403404
openfeature: TESTPATH=tests/integrations/openfeature
404405
opentelemetry: TESTPATH=tests/integrations/opentelemetry
405406
potel: TESTPATH=tests/integrations/opentelemetry

scripts/split_tox_gh_actions/split_tox_gh_actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"cohere",
6464
"langchain",
6565
"openai",
66+
"openai_agents",
6667
"huggingface_hub",
6768
],
6869
"Cloud": [

0 commit comments

Comments
 (0)