Skip to content

fix: guard __dict__ access with is not None checks for optional tool fields#1408

Open
PHclaw wants to merge 1 commit into
AgentOps-AI:mainfrom
PHclaw:main
Open

fix: guard __dict__ access with is not None checks for optional tool fields#1408
PHclaw wants to merge 1 commit into
AgentOps-AI:mainfrom
PHclaw:main

Conversation

@PHclaw

@PHclaw PHclaw commented Jun 18, 2026

Copy link
Copy Markdown

Summary

hasattr() returns True even when an optional field value is None, causing AttributeError: 'NoneType' object has no attribute '__dict__' when OpenAI Agents SDK WebSearchTool/FileSearchTool have optional fields (user_location, filters, ranking_options) set to None.

Changes

In agentops/instrumentation/providers/openai/attributes/response.py, added is not None guards alongside existing hasattr() checks in three places:

  • get_response_tool_web_search_attributes: tool.user_location.__dict__
  • get_response_tool_file_search_attributes: tool.filters.__dict__
  • get_response_tool_file_search_attributes: tool.ranking_options.__dict__

Fixes

Fixes #1285

Testing

Verified the fix with the reproduction case from #1285 — OpenAI Agents SDK WebSearchTool/FileSearchTool with None-valued optional fields no longer crash on_span_end.

…fields

hasattr() returns True even when the optional field value is None,
causing AttributeError: 'NoneType' object has no attribute '__dict__'
when OpenAI Agents SDK WebSearchTool/FileSearchTool have optional
fields (user_location, filters, ranking_options) set to None.

Fixes AgentOps-AI#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.

[Bug]: AttributeError: 'NoneType' object has no attribute '__dict__' in get_response_tool_web/file_search_attributes

1 participant