-
Notifications
You must be signed in to change notification settings - Fork 583
fix(openai-agents): Patch models functions following library refactor #5449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: webb/openai-agents/tool-patches
Are you sure you want to change the base?
fix(openai-agents): Patch models functions following library refactor #5449
Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛Openai Agents
Other
Documentation 📚
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 4.48s All tests are passing successfully. ❌ Patch coverage is 1.33%. Project has 13672 uncovered lines. Files with missing lines (180)
Generated by Codecov Action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
ericapisani
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small things, but otherwise LGTM 🚀
| @wraps(original_fetch_response) | ||
| async def wrapped_fetch_response(*args: "Any", **kwargs: "Any") -> "Any": | ||
| response = await original_fetch_response(*args, **kwargs) | ||
| if hasattr(response, "model") and response.model: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I think an alternative approach that you could take here in order to make this conditional more concise (by removing the and part of the conditional) is to do the following:
| if hasattr(response, "model") and response.model: | |
| if getattr(response, "model", None): |
This would also make things consistent with what you have on line 119 within the wrapped_get_response function.
| # Uses explicit try/finally instead of context manager to ensure cleanup | ||
| # even if the consumer abandons the stream (GeneratorExit). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment looks like it needs to be updated or removed as there's no try/finally below and the code uses a context manager 😅
| if hasattr(streaming_response, "model") | ||
| and streaming_response.model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a nitpick but similar to the comment I left above
Description
The
AgentRunner._get_model()class method has been moved to the functionagents.run_internal.turn_preparation.get_model().Patch the new function by re-using existing wrapper logic.
Issues
Reminders
tox -e linters.feat:,fix:,ref:,meta:)