o
    BDi                     @   sX   d dl mZ d dlZddlmZ ddlmZ d dlmZ er&d dlm	Z	m
Z
 dd	 ZdS )
    wrapsN   )agent_workflow_span)_capture_exception)TYPE_CHECKING)AnyCallablec                    s   t   fdd}|S )z
    Wraps the agents.Runner.run methods to create a root span for the agent workflow runs.

    Note agents.Runner.run_sync() is a wrapper around agents.Runner.run(),
    so it does not need to be wrapped separately.
    c                     s   | d }t |? d }z | i |I d H }|W W  d    S  tyG } zt| t }|d ur@|jd u r@|d d d  |d d }~ww 1 sKw   Y  d S )Nr   )r   	Exceptionr   
sentry_sdkget_current_span	timestamp__exit__)argskwargsagentresultexccurrent_spanoriginal_func m/var/www/Datamplify/venv/lib/python3.10/site-packages/sentry_sdk/integrations/openai_agents/patches/runner.pywrapper   s"   
z$_create_run_wrapper.<locals>.wrapperr   )r   r   r   r   r   _create_run_wrapper   s   	r   )	functoolsr   r   spansr   utilsr   typingr   r   r	   r   r   r   r   r   <module>   s    