Skip to content

Conversation

@alexander-alderman-webb
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb commented Nov 27, 2025

Description

Using sentry_sdk.get_current_span() is problematic with the asyncio integration. The integration forks the isolation and current scopes, so sentry_sdk.get_current_span() can return a span that does not correspond to the agent invocation.

The coroutine in which the agent span is entered finishes before the agent span is finished. When the coroutine exits, its scopes are popped, and the agent invocation span is lost before it is exited. You can confirm by setting breakpoints in the asyncio and openai-agents integrations, and running the reproduction provided in #5067.

See more details here #5067 (comment).

Issues

Closes #5067

Reminders

@alexander-alderman-webb alexander-alderman-webb changed the title fix(openai-agents): Store invoke_agent span on agents.RunContextWrapper fix(openai-agents): Store invoke_agent span on agents.RunContextWrapper Nov 27, 2025
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review November 27, 2025 12:29
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner November 27, 2025 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: in OpenAIAgentsIntegration + AsyncioIntegration: '_context_manager_state' not found

2 participants