Skip to content

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

Merged
areibman merged 1 commit into
AgentOps-AI:mainfrom
PHclaw:main
Jun 25, 2026
Merged

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

Conversation

@PHclaw

@PHclaw PHclaw commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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
@PHclaw

PHclaw commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Bumping this - hasattr() returns True even when the optional field is None, causing AttributeError on __dict__ access for WebSearchTool/FileSearchTool. This is a real crash with OpenAI Agents SDK. The fix adds is not None guards. Would appreciate any feedback on merging. Thanks!

@areibman areibman merged commit f8e907b into AgentOps-AI:main Jun 25, 2026
1 of 49 checks passed
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

2 participants