PHP 8.3.31
Preview: handoff.py Size: 723 B
//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)

Directory Contents

Dirs: 1 × Files: 6

Name Size Perms Modified Actions
- drwxr-xr-x 2026-06-11 06:30:31
Edit Download
459 B lrw-r--r-- 2026-06-11 06:30:31
Edit Download
2.12 KB lrw-r--r-- 2026-06-11 06:30:31
Edit Download
1.47 KB lrw-r--r-- 2026-06-11 06:30:31
Edit Download
723 B lrw-r--r-- 2026-06-11 06:30:31
Edit Download
3.09 KB lrw-r--r-- 2026-06-11 06:30:31
Edit Download
380 B lrw-r--r-- 2026-06-11 06:30:31
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).