HEX
Server: LiteSpeed
System: Linux server107.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: iddeczhh (1154)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/openai_agents/spans/handoff.py
from typing import TYPE_CHECKING

import sentry_sdk
from sentry_sdk.consts import OP, SPANDATA

from ..consts import SPAN_ORIGIN

if TYPE_CHECKING:
    import agents


def handoff_span(
    context: "agents.RunContextWrapper", from_agent: "agents.Agent", to_agent_name: str
) -> None:
    with sentry_sdk.start_span(
        op=OP.GEN_AI_HANDOFF,
        name=f"handoff from {from_agent.name} to {to_agent_name}",
        origin=SPAN_ORIGIN,
    ) as span:
        span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "handoff")

        # Add conversation ID from agent
        conv_id = getattr(from_agent, "_sentry_conversation_id", None)
        if conv_id:
            span.set_data(SPANDATA.GEN_AI_CONVERSATION_ID, conv_id)