Skip to content

Commit c4a5366

Browse files
mypy
1 parent 5a5f81d commit c4a5366

5 files changed

Lines changed: 9 additions & 5 deletions

File tree

sentry_sdk/integrations/openai_agents/spans/agent_workflow.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
from ..consts import SPAN_ORIGIN
88

99
if TYPE_CHECKING:
10+
from typing import Union
11+
1012
import agents
1113

1214

13-
def agent_workflow_span(agent: "agents.Agent") -> "sentry_sdk.tracing.Span":
15+
def agent_workflow_span(
16+
agent: "agents.Agent",
17+
) -> "Union[sentry_sdk.tracing.Span, sentry_sdk.traces.StreamedSpan]":
1418
# Create a transaction or a span if an transaction is already active
1519
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
1620
if span_streaming:

sentry_sdk/integrations/openai_agents/spans/ai_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
def ai_client_span(
2323
agent: "Agent", get_response_kwargs: "dict[str, Any]"
24-
) -> "sentry_sdk.tracing.Span":
24+
) -> "Union[sentry_sdk.tracing.Span, StreamedSpan]":
2525
# TODO-anton: implement other types of operations. Now "chat" is hardcoded.
2626
# Get model name from agent.model or fall back to request model (for when agent.model is None/default)
2727
model_name = None

sentry_sdk/integrations/openai_agents/spans/execute_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
def execute_tool_span(
1919
tool: "agents.Tool", *args: "Any", **kwargs: "Any"
20-
) -> "sentry_sdk.tracing.Span":
20+
) -> "Union[sentry_sdk.tracing.Span, StreamedSpan]":
2121
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
2222
if span_streaming:
2323
span = sentry_sdk.traces.start_span(

sentry_sdk/integrations/openai_agents/spans/handoff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def handoff_span(
2626
# Add conversation ID from agent
2727
conv_id = getattr(from_agent, "_sentry_conversation_id", None)
2828
if conv_id:
29-
span.set_data(SPANDATA.GEN_AI_CONVERSATION_ID, conv_id)
29+
span.set_attribute(SPANDATA.GEN_AI_CONVERSATION_ID, conv_id)
3030
else:
3131
with sentry_sdk.start_span(
3232
op=OP.GEN_AI_HANDOFF,

sentry_sdk/integrations/openai_agents/spans/invoke_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
def invoke_agent_span(
2626
context: "agents.RunContextWrapper", agent: "agents.Agent", kwargs: "dict[str, Any]"
27-
) -> "sentry_sdk.tracing.Span":
27+
) -> "Union[sentry_sdk.tracing.Span, StreamedSpan]":
2828
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
2929
if span_streaming:
3030
span = sentry_sdk.traces.start_span(

0 commit comments

Comments
 (0)