Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions sentry_sdk/integrations/pydantic_ai/patches/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def _patch_tool_execution():
original_call_tool = ToolManager._call_tool

@wraps(original_call_tool)
async def wrapped_call_tool(self, call, allow_partial, wrap_validation_errors):
# type: (Any, Any, bool, bool) -> Any
async def wrapped_call_tool(self, call, *args, **kwargs):
# type: (Any, Any, *Any, **Any) -> Any

# Extract tool info before calling original
name = call.tool_name
Expand All @@ -64,18 +64,14 @@ async def wrapped_call_tool(self, call, allow_partial, wrap_validation_errors):

with execute_tool_span(name, args_dict, agent, tool_type=tool_type) as span:
try:
result = await original_call_tool(
self, call, allow_partial, wrap_validation_errors
)
result = await original_call_tool(self, call, *args, **kwargs)
update_execute_tool_span(span, result)
return result
except Exception as exc:
_capture_exception(exc)
raise exc from None

# No span context - just call original
return await original_call_tool(
self, call, allow_partial, wrap_validation_errors
)
return await original_call_tool(self, call, *args, **kwargs)

ToolManager._call_tool = wrapped_call_tool
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ deps =
openai_agents: pytest-asyncio

pydantic_ai-v1.0.18: pydantic-ai==1.0.18
pydantic_ai-v1.3.0: pydantic-ai==1.3.0
pydantic_ai-v1.6.0: pydantic-ai==1.6.0
pydantic_ai-v1.10.0: pydantic-ai==1.10.0
pydantic_ai-v1.4.0: pydantic-ai==1.4.0
pydantic_ai-v1.8.0: pydantic-ai==1.8.0
pydantic_ai-v1.12.0: pydantic-ai==1.12.0
pydantic_ai: pytest-asyncio


Expand Down
Loading