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: 1 addition & 6 deletions sentry_sdk/integrations/pydantic_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,14 @@ class PydanticAIIntegration(Integration):
identifier = "pydantic_ai"
origin = f"auto.ai.{identifier}"

def __init__(
self, include_prompts: bool = True, handled_tool_call_exceptions: bool = True
) -> None:
def __init__(self, handled_tool_call_exceptions: bool = True) -> None:
"""
Initialize the Pydantic AI integration.

Args:
include_prompts: Whether to include prompts and messages in span data.
Requires send_default_pii=True. Defaults to True.
handled_tool_exceptions: Capture tool call exceptions that Pydantic AI
internally prevents from bubbling up.
"""
self.include_prompts = include_prompts
self.handled_tool_call_exceptions = handled_tool_call_exceptions

@staticmethod
Expand Down
25 changes: 2 additions & 23 deletions sentry_sdk/integrations/pydantic_ai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,20 @@
from pydantic_ai.settings import ModelSettings


def _should_send_prompts_legacy() -> bool:
"""
Check if prompts should be sent to Sentry based on the deprecated
``send_default_pii`` option and the ``include_prompts`` integration setting.

TODO: Remove this once `send_default_pii` is deprecated.
"""
if not should_send_default_pii():
return False

from . import PydanticAIIntegration

# Get the integration instance from the client
integration = sentry_sdk.get_client().get_integration(PydanticAIIntegration)

if integration is None:
return False

return getattr(integration, "include_prompts", False)


def _should_send_inputs() -> bool:
client = sentry_sdk.get_client()
if has_data_collection_enabled(client.options):
return bool(client.options["data_collection"]["gen_ai"]["inputs"])

return _should_send_prompts_legacy()
return should_send_default_pii()


def _should_send_outputs() -> bool:
client = sentry_sdk.get_client()
if has_data_collection_enabled(client.options):
return bool(client.options["data_collection"]["gen_ai"]["outputs"])

return _should_send_prompts_legacy()
return should_send_default_pii()


def _set_agent_data(span: "Span", agent: "Optional[Agent]") -> None:
Expand Down
Loading
Loading