ref(openai-agents): Use first class agent hooks when available - #7029
Open
alexander-alderman-webb wants to merge 18 commits into
Open
ref(openai-agents): Use first class agent hooks when available#7029alexander-alderman-webb wants to merge 18 commits into
alexander-alderman-webb wants to merge 18 commits into
Conversation
Contributor
Codecov Results 📊✅ 97214 passed | ⏭️ 6239 skipped | Total: 103453 | Pass Rate: 93.97% | Execution Time: 358m 25s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 89.32%. Project has 2494 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 89.90% 90.00% +0.1%
==========================================
Files 193 193 —
Lines 24822 24936 +114
Branches 8924 8974 +50
==========================================
+ Hits 22315 22442 +127
- Misses 2507 2494 -13
- Partials 1417 1423 +6Generated by Codecov Action |
alexander-alderman-webb
changed the base branch from
webb/use-agent-hooks
to
webb/fix-run_single_turn_streamed-patch
August 4, 2026 13:09
alexander-alderman-webb
marked this pull request as ready for review
August 4, 2026 15:09
alexander-alderman-webb
marked this pull request as draft
August 4, 2026 15:33
alexander-alderman-webb
marked this pull request as ready for review
August 5, 2026 14:03
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.
Reviewed by Cursor Bugbot for commit 8343310. Configure here.
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Add
on_agent_start(),on_agent_end()andon_handoff()hooks.Unlike tool hooks, the Invoke Agent span is stored on the
RunHooksinstance.If the hooks are active, start and finish Invoke Agent spans in the hooks in successful executions. If an exception bubbles up,
on_agent_end()does not run. Modify monkey-patches so that the span stored on theRunHooksinstance is finished if the hooks are present.Make the signatures of
invoke_agent_span(),update_invoke_agent_span()and_maybe_start_agent_span()more minimal so that they can be re-used in theon_agent_start()andon_agent_end()hooks.Issues
Closes #6989
Reminders
uv run ruff.feat:,fix:,ref:,meta:)