pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/modelcontextprotocol/python-sdk/pull/2347

bd78641c0a1f3e0.css" /> Fix AttributeError when tool fields are None in OpenAI Agents SDK instrumentation (#1285) by YouFoxGirl · Pull Request #2347 · modelcontextprotocol/python-sdk · GitHub
Skip to content

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

Open
YouFoxGirl wants to merge 1 commit intomodelcontextprotocol:mainfrom
YouFoxGirl:fix/1285-none-attribute-crash
Open

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

Conversation

@YouFoxGirl
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
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.

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy