FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ref(openai-agents): Use first class tool hooks when available by alexander-alderman-webb · Pull Request #6994 · getsentry/sentry-python · GitHub

ref(openai-agents): Use first class tool hooks when available - #6994

Merged
alexander-alderman-webb merged 15 commits into
masterfrom
webb/use-tool-hooks
Aug 6, 2026
Merged

ref(openai-agents): Use first class tool hooks when available#6994
alexander-alderman-webb merged 15 commits into
masterfrom
webb/use-tool-hooks

Conversation

alexander-alderman-webb commented Aug 3, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Description

Register a RunHooks instance or patch a user-provided hooks instance if it exists. Inject the resulting instance as the hooks keyword-only argument to AgentRunner.run() and AgentRunner.run_streamed().

Note that the hooks are only added starting with openai-agents version 0.3.2 as tool call arguments are unavailable in prior versions.

The openai-agents/patches/tools.py file can be removed in the next major due to redundancy with the hooks.

Rename responses_tool_call_model_responses by prefixing the fixture with nonstreaming_, and add a minimal equivalent streaming fixture. Add a variant of the test_tool_execution_span test that calls AgentRunner.run_streamed() instead of AgentRunner.run().

Issues

Closes #6988

Reminders

github-actions Bot commented Aug 3, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Codecov Results 📊

95743 passed | ⏭️ 6239 skipped | Total: 101982 | Pass Rate: 93.88% | Execution Time: 350m 2s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +180
Passed Tests 📈 +180
Failed Tests
Skipped Tests

All tests are passing successfully.

✅ Patch coverage is 94.59%. Project has 2509 uncovered lines.
✅ Project coverage is 89.92%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
sentry_sdk/integrations/openai_agents/patches/runner.py 94.74% ⚠️ 3 Missing and 4 partials
sentry_sdk/integrations/openai_agents/patches/tools.py 87.50% ⚠️ 1 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.92%    89.92%        —%
==========================================
  Files          193       193         —
  Lines        24825     24880       +55
  Branches      8912      8936       +24
==========================================
+ Hits         22321     22371       +50
- Misses        2504      2509        +5
- Partials      1414      1421        +7

Generated by Codecov Action

alexander-alderman-webb marked this pull request as ready for review August 3, 2026 14:21
alexander-alderman-webb requested a review from a team as a code owner August 3, 2026 14:21

cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Cursor Bugbot has reviewed your changes and found 2 potential issues.

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bb76a15. Configure here.

alexander-alderman-webb marked this pull request as draft August 3, 2026 17:07
alexander-alderman-webb marked this pull request as ready for review August 3, 2026 17:08

sentrivana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Lgtm.

The openai-agents/patches/tools.py file can be removed in the next major due to redundancy with the hooks.

Let's add a comment to the file so that we don't forget?

alexander-alderman-webb merged commit 8dfb03c into master Aug 6, 2026
142 of 145 checks passed
alexander-alderman-webb deleted the webb/use-tool-hooks branch August 6, 2026 06:48
mgaligniana pushed a commit to mgaligniana/sentry-python that referenced this pull request Aug 9, 2026
…try#6994)

Register a `RunHooks` instance, or patch a user-provided hooks instance if it exists. Inject the resulting instance as the `hooks` keyword-only argument to `AgentRunner.run()` and `AgentRunner.run_streamed()`.

Note that the hooks are only added starting with `openai-agents` version 0.3.2, since tool call arguments are unavailable in prior versions.

Rename `responses_tool_call_model_responses` by prefixing the fixture with `nonstreaming_`, add a minimal equivalent streaming fixture, and add a variant of the `test_tool_execution_span` test that calls `AgentRunner.run_streamed()` instead of `AgentRunner.run()`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Use RunHooks.on_tool_start and RunHooks.on_tool_end

2 participants


Back | FazBrowse Home | New Git URL