PATH:
opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
sentry_sdk
/
integrations
/
pydantic_ai
/
patches
/
__pycache__
� o0i� � �� � d dl mZ d dlmZ d dlZddlmZmZ ddlm Z m Z d dlmZ erd dlm Z d d lmZ d Z d dlmZ d� Zy# e$ r dZY �w xY w# e$ r ed � �w xY w)� )�wraps)�DidNotEnableN� )�execute_tool_span�update_execute_tool_span)�_capture_exception�get_current_agent)� TYPE_CHECKING)�Any)� MCPServerTF)�ToolManagerzpydantic-ai not installedc �b �� t j �t �� �fd�� } | t _ y)a� Patch ToolManager._call_tool to create execute_tool spans. This is the single point where ALL tool calls flow through in pydantic_ai, regardless of toolset type (function, MCP, combined, wrapper, etc.). By patching here, we avoid: - Patching multiple toolset classes - Dealing with signature mismatches from instrumented MCP servers - Complex nested toolset handling c � �� �K � |j }| j r| j j |� nd }d}|r"t rt |j t � rd}t � }|rn|rl |j � }t j � 5 t ||||�� 5 } �| |g|��i |��� d { ��� } t | | � | cd d d � cd d d � S �| |g|��i |��� d { ��� S # t $ r+ t |j t � r|j ni }Y ��w xY w7 �p# t $ r}t! |� |d �d }~ww xY w# 1 sw Y nxY w d d d � ��# 1 sw Y ��xY w7 �~�w)N�function�mcp)� tool_type)� tool_name�tools�get�HAS_MCP� isinstance�toolsetr r �args_as_dict� Exception�args�dict� sentry_sdk�isolation_scoper r r ) �self�callr �kwargs�name�toolr �agent� args_dict�span�result�exc�original_call_tools ��`/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/pydantic_ai/patches/tools.py�wrapped_call_toolz0_patch_tool_execution.<locals>.wrapped_call_tool. s� �� �� � �~�~��'+�z�z�t�z�z�~�~�d�#�t�� � ��G� �4�<�<�� C��I� "�#���T� M� �-�-�/� � �+�+�-�&����'� � �,�'9� � �(� "�(� %� (� "�� 1��v�>�%�� � .�-�* (��� � � � � � � ��5 � M�)3�D�I�I�t�)D�D�I�I�"� � M��"�� %� ,�*�3�/�!�t�+��,��� �� � .�-�-��* �s� �A*E*�.C. �>E*�E�"E�$D'�4D%�5D'� E�E*�)E(�*E*�.1D"�E*�!D"�"E*�%D'�' E�0D>�>E�E�E �E� E*�E%�!E*N)r � _call_toolr )r+ r) s @r* �_patch_tool_executionr- s4 �� � %�/�/�� ���1 � �1 �f /�K�� )� functoolsr �sentry_sdk.integrationsr r �spansr r �utilsr r �typingr r �pydantic_ai.mcpr r �ImportError�pydantic_ai._tool_managerr r- � r. r* �<module>r8 sn �� � 0� � ?�� !����)��G�4�5� D/�� � ��G��� � 4� �2� 3�3�4�s �A �A �A �A �A
[-] graph_nodes.cpython-312.pyc
[edit]
[-] agent_run.cpython-312.pyc
[edit]
[+]
..
[-] tools.cpython-312.pyc
[edit]
[-] __init__.cpython-312.pyc
[edit]
[-] model_request.cpython-312.pyc
[edit]