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

Fix AttributeError when tool fields are None in OpenAI Agents SDK instrumentation (#1285) by YouFoxGirl · Pull Request #2347 · modelcontextprotocol/python-sdk · GitHub

Fix AttributeError when tool fields are None in OpenAI Agents SDK instrumentation (#1285) - #2347

Closed
YouFoxGirl wants to merge 1 commit into
modelcontextprotocol:mainfrom
YouFoxGirl:fix/1285-none-attribute-crash
Closed

Fix AttributeError when tool fields are None in OpenAI Agents SDK instrumentation (#1285)#2347
YouFoxGirl wants to merge 1 commit into
modelcontextprotocol:mainfrom
YouFoxGirl:fix/1285-none-attribute-crash

Conversation

Copy link
Copy Markdown

Summary

In get_response_tool_web_search_attributes() and get_response_tool_file_search_attributes(), hasattr() returns True for optional fields set to None, but accessing .__dict__ on None raises AttributeError.

Fix

Added is not None guard for user_location, filters, and ranking_options fields in agentops/instrumentation/providers/openai/attributes/response.py:

# Before (buggy)
if hasattr(tool, "user_location"):
    parameters["user_location"] = tool.user_location.__dict__

# After (fixed)
if hasattr(tool, "user_location") and tool.user_location is not None:
    parameters["user_location"] = tool.user_location.__dict__

Same pattern applied to filters and ranking_options.

Testing

Added regression tests in tests/unit/instrumentation/providers/openai/test_response_issue_1285.py covering all three None-field cases. All 5 tests pass.

Fixes #1285

…trumentation

In get_response_tool_web_search_attributes() and get_response_tool_file_search_attributes(), hasattr() returns True for optional fields set to None, but accessing .__dict__ on None raises AttributeError. Added is not None guard for user_location, filters, and ranking_options fields.

Fixes modelcontextprotocol#1285

Copy link
Copy Markdown
Contributor

Closing — this adds files under agentops/instrumentation/..., which doesn't exist in this repo. It looks like this PR was intended for a different project.

AI Disclaimer

maxisbey closed this May 18, 2026
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.

2 participants


Back | FazBrowse Home | New Git URL