fix(openai_agents): correctly patch turn_preparation.get_model to capture model spans - #7227
Open
x-tahosin wants to merge 2 commits into
Open
fix(openai_agents): correctly patch turn_preparation.get_model to capture model spans#7227x-tahosin wants to merge 2 commits into
x-tahosin wants to merge 2 commits into
Conversation
…urately Fixes missing hook in the openai_agents integration that prevents Sentry from capturing dynamic tool calls when using the openai Swarm/Agents SDK.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3508792. Configure here.
|
|
||
| agents.run_internal.run_loop.get_model = new_wrapped_get_model | ||
|
|
||
| if not use_run_hooks and hasattr(run_loop, "get_all_tools"): |
There was a problem hiding this comment.
Unreachable get_all_tools patch
High Severity
The new get_all_tools wrap is gated on not use_run_hooks, but this block only runs for openai-agents >= 0.8, where use_run_hooks is always true. The condition can never succeed, so the patch never installs and the PR's intended tool-call spans stay missing.
Reviewed by Cursor Bugbot for commit 3508792. Configure here.
x-tahosin
force-pushed
the
codex/bugsmash-streamed-tool-spans
branch
from
August 23, 2026 17:17
3508792 to
ecb315d
Compare
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
Fixes a typo in the
openai_agentsintegration where theget_modelfunction was incorrectly assigned to the wrong namespace.In
sentry_sdk/integrations/openai_agents/__init__.py, the documentation states that foropenai-agents >= 0.8.0,AgentRunner._get_model()was refactored toagents.run_internal.turn_preparation.get_model(). The integration correctly wrapsturn_preparation.get_model, but then incorrectly assigns the wrapped function back toagents.run_internal.run_loop.get_model.Because
run_loop.get_modelis not used by theopenai-agentsSDK internally to fetch the model, the wrapped method is never called, andgen_ai.model.invokespans may be missed or misattributed.This PR fixes the assignment target to
agents.run_internal.turn_preparation.get_model, ensuring the correct function is patched and the span is successfully tracked.Solution
Changed the assignment from
run_loop.get_modeltoturn_preparation.get_model.