Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

'Span' object has no attribute '_context_manager_state' #4718

Copy link
Copy link

Description

@Afstkla
Issue body actions

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.init(
    dsn="...",
    send_default_pii=True,
    traces_sample_rate=1.0,
    integrations=[
        OpenAIAgentsIntegration(),
    ],
)


main_agent = Agent(
    name="main_agent",
    model="gpt-5",
)


async def run_agent() -> None:
    runner = await Runner.run(
        starting_agent=main_agent,
        input="How are you?",
    )
    print(runner.final_output)


async def main() -> None:
    await asyncio.gather(*[run_agent() for _ in range(2)])


if __name__ == "__main__":
    asyncio.run(main())

Then, the agent that finishes 2nd will fail with:

{
  "error": "'Span' object has no attribute '_context_manager_state'",
  "tool_name": "<agentname>_agent"
}

Expected Result

  1. This error not to happen
  2. 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

Actual Result

The 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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

Status
Waiting for: Product Owner
Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.