Skip to content

Conversation

@wingding12
Copy link

@wingding12 wingding12 commented Jan 27, 2026

summary

Fixes #1105

the OpenAI Agents SDK instrumentation was missing handlers for GuardrailSpanData, causing guardrail events to be incorrectly classified as generic events instead of proper GUARDRAIL span types.

problem

two functions in the OpenAI Agents SDK instrumentation were missing handlers for GuardrailSpanData:

  1. get_span_kind() in exporter.py - didn't handle GuardrailSpanData
  2. get_span_attributes() in attributes/common.py - didn't have a case for GuardrailSpanData

solution

add:

  • GuardrailSpanData case to get_span_kind() returning SpanKind.INTERNAL
  • GUARDRAIL_SPAN_ATTRIBUTES mapping for attribute extraction
  • get_guardrail_span_attributes() function to extract guardrail-specific attributes
  • GuardrailSpanData case to get_span_attributes() dispatcher
  • comprehensive tests for guardrail span attribute extraction

other changes

guardrail spans now properly include:

  • guardrail.name: The name of the guardrail
  • guardrail.triggered: Whether the guardrail was activated (boolean)
  • agentops.span.kind: Set to "guardrail" for proper classification=

Fixes AgentOps-AI#1105

The OpenAI Agents SDK instrumentation was missing handlers for GuardrailSpanData,
causing guardrail events to be incorrectly classified as generic events instead
of proper GUARDRAIL span types.

Changes:
- Add GuardrailSpanData case to get_span_kind() in exporter.py
- Add GUARDRAIL_SPAN_ATTRIBUTES mapping in attributes/common.py
- Add get_guardrail_span_attributes() function to extract guardrail attributes
- Add GuardrailSpanData case to get_span_attributes() dispatcher
- Add tests for guardrail span attribute extraction

The guardrail spans now properly include:
- guardrail.name: The name of the guardrail
- guardrail.triggered: Whether the guardrail was activated
- agentops.span.kind: Set to "guardrail" for proper classification
@wingding12 wingding12 marked this pull request as draft January 27, 2026 16:17
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.

OpenAI Agents SDK Guardrail Span Classification Issues

1 participant