Skip to content

merge master

bf37fa2
Select commit
Loading
Failed to load commit list.
Open

feat(openai-agents): Support span streaming #6404

merge master
bf37fa2
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed May 26, 2026 in 56m 53s

1 issue

code-review: Found 1 issue (1 medium)

Medium

`invoke_agent_span.timestamp` raises AttributeError for StreamedSpan in AgentsException handler - `sentry_sdk/integrations/openai_agents/patches/runner.py:47-54`

When span streaming is enabled, invoke_agent_span can be a StreamedSpan, which uses __slots__ and has no timestamp attribute (only end_timestamp). Accessing .timestamp at line 73 raises AttributeError, which is silently swallowed by capture_internal_exceptions, leaving the invoke-agent span dangling/unclosed when an AgentsException is raised. Apply the same isinstance(invoke_agent_span, StreamedSpan) pattern used in this hunk: check end_timestamp is None for StreamedSpan and timestamp is None for regular spans.

Also found at:

  • tests/integrations/openai_agents/test_openai_agents.py:1615

⏱ 55m 45s · 6.5M in / 213.6k out · $8.81

Annotations

Check warning on line 54 in sentry_sdk/integrations/openai_agents/patches/runner.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

`invoke_agent_span.timestamp` raises AttributeError for StreamedSpan in AgentsException handler

When span streaming is enabled, `invoke_agent_span` can be a `StreamedSpan`, which uses `__slots__` and has no `timestamp` attribute (only `end_timestamp`). Accessing `.timestamp` at line 73 raises `AttributeError`, which is silently swallowed by `capture_internal_exceptions`, leaving the invoke-agent span dangling/unclosed when an `AgentsException` is raised. Apply the same `isinstance(invoke_agent_span, StreamedSpan)` pattern used in this hunk: check `end_timestamp is None` for `StreamedSpan` and `timestamp is None` for regular spans.

Check warning on line 1615 in tests/integrations/openai_agents/test_openai_agents.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

[95E-WCB] `invoke_agent_span.timestamp` raises AttributeError for StreamedSpan in AgentsException handler (additional location)

When span streaming is enabled, `invoke_agent_span` can be a `StreamedSpan`, which uses `__slots__` and has no `timestamp` attribute (only `end_timestamp`). Accessing `.timestamp` at line 73 raises `AttributeError`, which is silently swallowed by `capture_internal_exceptions`, leaving the invoke-agent span dangling/unclosed when an `AgentsException` is raised. Apply the same `isinstance(invoke_agent_span, StreamedSpan)` pattern used in this hunk: check `end_timestamp is None` for `StreamedSpan` and `timestamp is None` for regular spans.