ref(openai-agents): Use first class tool hooks when available - #6994
ref(openai-agents): Use first class tool hooks when available#6994alexander-alderman-webb wants to merge 15 commits into
Conversation
Codecov Results 📊✅ 95743 passed | ⏭️ 6239 skipped | Total: 101982 | Pass Rate: 93.88% | Execution Time: 350m 2s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 94.59%. Project has 2509 uncovered lines. Files with missing lines (2)
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 +7Generated by Codecov Action |
There was a problem hiding this comment.
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.
sentrivana
left a comment
There was a problem hiding this comment.
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?

Description
Register a
RunHooksinstance or patch a user-provided hooks instance if it exists. Inject the resulting instance as thehookskeyword-only argument toAgentRunner.run()andAgentRunner.run_streamed().Note that the hooks are only added starting with
openai-agentsversion 0.3.2 as tool call arguments are unavailable in prior versions.The
openai-agents/patches/tools.pyfile can be removed in the next major due to redundancy with the hooks.Rename
responses_tool_call_model_responsesby prefixing the fixture withnonstreaming_, and add a minimal equivalent streaming fixture. Add a variant of thetest_tool_execution_spantest that callsAgentRunner.run_streamed()instead ofAgentRunner.run().Issues
Closes #6988
Reminders
uv run ruff.feat:,fix:,ref:,meta:)