Skip to content

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

@md-armaan13

Description

@md-armaan13

Contact Details

md.armaan4210@gmail.com

πŸ“¦ Package Version

0.4.21

🎞️ Framework Version

OpenAI Agent SDK (0.6.7)

πŸ”Ž Describe the Bug

Bug Report

Description

When using the OpenAI Agents SDK with file search or web search tools, on_span_end raises:

ERROR:openai.agents:Error in trace processor <agentops.instrumentation.agentic.openai_agents.processor.OpenAIAgentsProcessor
object> during on_span_end: 'NoneType' object has no attribute 'dict'

Root Cause

In agentops/instrumentation/providers/openai/attributes/response.py, three hasattr() checks guard calls to .__dict__ on
optional tool fields β€” but hasattr() returns True even when the attribute value is None:

get_response_tool_web_search_attributes (line ~507):

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

get_response_tool_file_search_attributes (lines ~525, ~531):
if hasattr(tool, "filters"):
    parameters["filters"] = tool.filters.__dict__  # crashes if None

if hasattr(tool, "ranking_options"):
    parameters["ranking_options"] = tool.ranking_options.__dict__  # crashes if None

user_location, filters, and ranking_options are all optional fields that default to None in the OpenAI SDK models. The hasattr
guard is insufficient.

Fix

Add is not None checks alongside hasattr:

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

# FileSearchTool
if hasattr(tool, "filters") and tool.filters is not None:
    parameters["filters"] = tool.filters.__dict__

if hasattr(tool, "ranking_options") and tool.ranking_options is not None:
    parameters["ranking_options"] = tool.ranking_options.__dict__

Versions

- agentops==0.4.21
- openai-agents==0.6.7
- openai==2.15.0

Call Stack

on_span_end (processor.py)
  β†’ export_span (exporter.py)
    β†’ get_span_attributes (attributes/common.py)
      β†’ get_response_span_attributes
        β†’ get_response_response_attributes (providers/openai/attributes/response.py)
          β†’ get_response_tools_attributes
            β†’ get_response_tool_web/file_search_attributes  ← crash here

### 🀝 Contribution

- [x] Yes, I'd be happy to submit a pull request with these changes.
- [x] I need some guidance on how to contribute.
- [ ] I'd prefer the AgentOps team to handle this update.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions