Title: 'Span' object has no attribute '_context_manager_state' · Issue #4718 · getsentry/sentry-python · GitHub
Open Graph Title: 'Span' object has no attribute '_context_manager_state' · Issue #4718 · getsentry/sentry-python
X Title: 'Span' object has no attribute '_context_manager_state' · Issue #4718 · getsentry/sentry-python
Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce Run import asyncio import sentry_sdk from agents import Agent, Runner from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration sentry_sdk.i...
Open Graph Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce Run import asyncio import sentry_sdk from agents import Agent, Runner from sentry_sdk.integrations.openai_agents imp...
X Description: How do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce Run import asyncio import sentry_sdk from agents import Agent, Runner from sentry_sdk.integrations.openai_agents imp...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/4718
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"'Span' object has no attribute '_context_manager_state'","articleBody":"### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Version\n\n2.35.0\n\n### Steps to Reproduce\n\nRun\n\n```python\nimport asyncio\n\nimport sentry_sdk\nfrom agents import Agent, Runner\nfrom sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration\n\nsentry_sdk.init(\n dsn=\"...\",\n send_default_pii=True,\n traces_sample_rate=1.0,\n integrations=[\n OpenAIAgentsIntegration(),\n ],\n)\n\n\nmain_agent = Agent(\n name=\"main_agent\",\n model=\"gpt-5\",\n)\n\n\nasync def run_agent() -> None:\n runner = await Runner.run(\n starting_agent=main_agent,\n input=\"How are you?\",\n )\n print(runner.final_output)\n\n\nasync def main() -> None:\n await asyncio.gather(*[run_agent() for _ in range(2)])\n\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n```\n\nThen, the agent that finishes 2nd will fail with:\n\n```json\n{\n \"error\": \"'Span' object has no attribute '_context_manager_state'\",\n \"tool_name\": \"\u003cagentname>_agent\"\n}\n```\n\n### Expected Result\n\n1. This error not to happen\n2. That most (if not all) parts of the Sentry SDK are wrapped in `try catch` blocks, so that if for some reason like now a `Span` cannot be closed, it doesn't interfere with the normal flow\n\n### Actual Result\n\nThe agent crashes, and instead of the result that was generated by the nested agent being available to the main agent, the main agent only sees the error message and cannot continue.","author":{"url":"https://github.com/Afstkla","@type":"Person","name":"Afstkla"},"datePublished":"2025-08-25T09:27:46Z","url":"https://github.com/getsentry/sentry-python/issues/4718"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0fdbbfab-f497-7c92-d8fe-de892a56f930 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9C8:39F538:372E60:4C643C:6B008B96 |
| html-safe-nonce | b39f4812568de091ae8dedb1c9dc092db3f562a2c070bc5bb689aaae7dea9c26 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUM4OjM5RjUzODozNzJFNjA6NEM2NDNDOjZCMDA4Qjk2IiwidmlzaXRvcl9pZCI6IjkxOTE3Njg4ODMzMDY5OTA0ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 560b331d3752da622ea28e5127ef06e031fa03c1611e41b31f38985fddbcdec2 |
| hovercard-subject-tag | issue:3351108712 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/4718/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1be020c7d2ff84d2e7c25046b0408403288b6581930fb6739369a62b4fcab3c1/getsentry/sentry-python/issues/4718 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1be020c7d2ff84d2e7c25046b0408403288b6581930fb6739369a62b4fcab3c1/getsentry/sentry-python/issues/4718 |
| og:image:alt | How do you use Sentry? Sentry Saas (sentry.io) Version 2.35.0 Steps to Reproduce Run import asyncio import sentry_sdk from agents import Agent, Runner from sentry_sdk.integrations.openai_agents imp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Afstkla |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width