Skip to content

Comments

fix(openai-agents): align AgentSpanData stubs and span processor with real SDK#4229

Open
nagkumar91 wants to merge 4 commits intoopen-telemetry:mainfrom
nagkumar91:fix/openai-agents-align-stubs-with-sdk
Open

fix(openai-agents): align AgentSpanData stubs and span processor with real SDK#4229
nagkumar91 wants to merge 4 commits intoopen-telemetry:mainfrom
nagkumar91:fix/openai-agents-align-stubs-with-sdk

Conversation

@nagkumar91
Copy link
Contributor

Description

Fixes test stubs and span processor code that referenced AgentSpanData fields (operation, description, agent_id, model) which never existed in the real OpenAI Agents SDK. The real SDK AgentSpanData only has: name, handoffs, tools, output_type.

Reported by @adammw in fa5f44e#r177563121

Changes

Test stubs (tests/stubs/agents/tracing/__init__.py)

  • Removed operation, description, agent_id, model from stub AgentSpanData
  • Added handoffs field to match real SDK
  • Updated agent_span() helper to match real SDK signature (positional name arg)

Span processor (span_processor.py)

  • Simplified _get_operation_name(): agent spans always return invoke_agent (real SDK has no operation field to distinguish create vs invoke)
  • Removed getattr(span_data, "agent_id"), getattr(span_data, "description"), getattr(span_data, "model") from _get_attributes_from_agent_span_data()
  • Kept: user-configured overrides (self.agent_id, self.agent_description) and model fallback from child span aggregation

Tests

  • Replaced test_agent_create_span_records_attributes with test_agent_invoke_span_records_attributes
  • Removed all uses of non-existent operation=, description=, agent_id=, model= kwargs from AgentSpanData() and agent_span() calls

All 103 tests pass.

Remove operation, description, agent_id, and model fields from the test
stub AgentSpanData that never existed in the real OpenAI Agents SDK
(openai/openai-agents-python). The real SDK AgentSpanData only has:
name, handoffs, tools, and output_type.

Changes:
- Remove fake fields from stub AgentSpanData, add handoffs to match SDK
- Update agent_span() stub to match real SDK signature (positional name)
- Simplify _get_operation_name(): agent spans always map to invoke_agent
- Remove getattr reads of non-existent agent_id/description/model from
  span_data in _get_attributes_from_agent_span_data(); keep user-
  configured overrides and model fallback from child span aggregation
- Fix all tests that used non-existent AgentSpanData fields

Reported-by: @adammw
Ref: open-telemetry@fa5f44e#r177563121

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

6 participants