Skip to content

Commit 9f2c047

Browse files
fix(openai-agents): Store invoke_agent span on agents.RunContextWrapper
1 parent a76280b commit 9f2c047

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

sentry_sdk/integrations/openai_agents/patches/agent_run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def _start_invoke_agent_span(context_wrapper, agent, kwargs):
3131
"""Start an agent invocation span"""
3232
# Store the agent on the context wrapper so we can access it later
3333
context_wrapper._sentry_current_agent = agent
34-
invoke_agent_span(context_wrapper, agent, kwargs)
34+
span = invoke_agent_span(context_wrapper, agent, kwargs)
35+
context_wrapper._sentry_agent_span = span
3536

3637
def _end_invoke_agent_span(context_wrapper, agent, output=None):
3738
# type: (agents.RunContextWrapper, agents.Agent, Optional[Any]) -> None

sentry_sdk/integrations/openai_agents/spans/invoke_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def invoke_agent_span(context, agent, kwargs):
7575

7676
def update_invoke_agent_span(context, agent, output):
7777
# type: (agents.RunContextWrapper, agents.Agent, Any) -> None
78-
span = sentry_sdk.get_current_span()
78+
span = context._sentry_agent_span
7979

8080
if span:
8181
if should_send_default_pii():

0 commit comments

Comments
 (0)