agentops
agentops copied to clipboard
fix: add None checks for optional tool fields in response attributes
Summary
- Adds
is not Nonechecks before accessing.__dict__on optional tool fields - Fixes
AttributeError: 'NoneType' object has no attribute '__dict__'when using OpenAI Agents SDK with web search or file search tools
Problem
WebSearchTool.user_location, FileSearchTool.filters, and FileSearchTool.ranking_options are optional fields that default to None in the OpenAI SDK. The existing hasattr() guards return True even when the attribute value is None, causing the .__dict__ access to crash.
Changes
In agentops/instrumentation/providers/openai/attributes/response.py:
get_response_tool_web_search_attributes: Addedand tool.user_location is not Noneget_response_tool_file_search_attributes: Addedand tool.filters is not Noneandand tool.ranking_options is not None
Test plan
- [ ] Verify web search tool with
user_location=Noneno longer crashes - [ ] Verify file search tool with
filters=Noneandranking_options=Noneno longer crashes - [ ] Verify tools with non-None values still extract attributes correctly
Fixes #1285
https://claude.ai/code/session_011TWMvnjeLgAJg9XtxoLfZT