Skip to content
Merged
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
7 changes: 6 additions & 1 deletion sentry_sdk/integrations/pydantic_ai/patches/agent_run.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from functools import wraps

import sentry_sdk
from sentry_sdk.integrations import DidNotEnable

from ..spans import invoke_agent_span, update_invoke_agent_span
from ..utils import _capture_exception, pop_agent, push_agent

from typing import TYPE_CHECKING
from pydantic_ai.agent import Agent # type: ignore

try:
from pydantic_ai.agent import Agent # type: ignore
except ImportError:
raise DidNotEnable("pydantic-ai not installed")

if TYPE_CHECKING:
from typing import Any, Callable, Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
from functools import wraps

import sentry_sdk
from sentry_sdk.integrations import DidNotEnable

from ..spans import (
ai_client_span,
update_ai_client_span,
)
from pydantic_ai._agent_graph import ModelRequestNode # type: ignore

try:
from pydantic_ai._agent_graph import ModelRequestNode # type: ignore
except ImportError:
raise DidNotEnable("pydantic-ai not installed")

from typing import TYPE_CHECKING

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from functools import wraps
from typing import TYPE_CHECKING

from pydantic_ai import models # type: ignore
from sentry_sdk.integrations import DidNotEnable

try:
from pydantic_ai import models # type: ignore
except ImportError:
raise DidNotEnable("pydantic-ai not installed")

from ..spans import ai_client_span, update_ai_client_span

Expand Down
8 changes: 6 additions & 2 deletions sentry_sdk/integrations/pydantic_ai/patches/tools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from functools import wraps

from pydantic_ai._tool_manager import ToolManager # type: ignore

from sentry_sdk.integrations import DidNotEnable
import sentry_sdk

from ..spans import execute_tool_span, update_execute_tool_span
Expand All @@ -22,6 +21,11 @@
except ImportError:
HAS_MCP = False

try:
from pydantic_ai._tool_manager import ToolManager # type: ignore
except ImportError:
raise DidNotEnable("pydantic-ai not installed")


def _patch_tool_execution():
# type: () -> None
Expand Down