PydanticAIIntegration fails with pydantic-ai-slim 1.63.0: ToolManager has no attribute '_call_tool'
Description
When using pydantic-ai-slim[openai]==1.63.0 with Sentry's auto-enabled Pydantic AI integration, the SDK fails during import/startup with:
AttributeError: type object 'ToolManager' has no attribute '_call_tool'
The integration patches ToolManager._call_tool in sentry_sdk/integrations/pydantic_ai/patches/tools.py (line 43: original_call_tool = ToolManager._call_tool), but in pydantic-ai-slim 1.63.0 the ToolManager class no longer exposes this attribute (or it was moved/renamed in the slim package).
Environment
- sentry-sdk: 2.53.0 (with
[fastapi])
- pydantic-ai-slim: 1.63.0 with
[openai] extra
- Python: 3.11
Expected behavior
The Pydantic AI integration should either:
- Detect that
ToolManager._call_tool is not present and skip the tool-execution patch (e.g. with getattr(ToolManager, '_call_tool', None)), or
- Document compatibility with pydantic-ai-slim and supported versions.
Actual behavior
Any code path that triggers loading of the Pydantic AI integration (e.g. importing an app that uses pydantic-ai) raises AttributeError and prevents startup. For example, pytest collection fails when collecting a test module that does from src.main import app.
Workaround
- Pin pydantic-ai-slim to 1.62.x (e.g.
==1.62.0), with which the integration works, or
- Disable the integration:
sentry_sdk.init(..., disabled_integrations=[PydanticAIIntegration])
Related
Reproduction
pip install "sentry-sdk[fastapi]==2.53.0" "pydantic-ai-slim[openai]==1.63.0"
- In application code, call
sentry_sdk.init(dsn="...", ...) (integration is auto-enabled when pydantic_ai is installed).
- Import a module that uses pydantic_ai (e.g. FastAPI app with agent routes).
- Observe
AttributeError: type object 'ToolManager' has no attribute '_call_tool' during the patch in _patch_tool_execution().
PydanticAIIntegration fails with pydantic-ai-slim 1.63.0: ToolManager has no attribute '_call_tool'
Description
When using
pydantic-ai-slim[openai]==1.63.0with Sentry's auto-enabled Pydantic AI integration, the SDK fails during import/startup with:The integration patches
ToolManager._call_toolinsentry_sdk/integrations/pydantic_ai/patches/tools.py(line 43:original_call_tool = ToolManager._call_tool), but in pydantic-ai-slim 1.63.0 theToolManagerclass no longer exposes this attribute (or it was moved/renamed in the slim package).Environment
[fastapi])[openai]extraExpected behavior
The Pydantic AI integration should either:
ToolManager._call_toolis not present and skip the tool-execution patch (e.g. withgetattr(ToolManager, '_call_tool', None)), orActual behavior
Any code path that triggers loading of the Pydantic AI integration (e.g. importing an app that uses pydantic-ai) raises
AttributeErrorand prevents startup. For example, pytest collection fails when collecting a test module that doesfrom src.main import app.Workaround
==1.62.0), with which the integration works, orsentry_sdk.init(..., disabled_integrations=[PydanticAIIntegration])Related
ToolManager._call_tool()parameters #5084 (fix for newToolManager._call_tool()parameters in pydantic-ai 1.12.0) fixed signature compatibility but not the case where the attribute is missing entirely.Reproduction
pip install "sentry-sdk[fastapi]==2.53.0" "pydantic-ai-slim[openai]==1.63.0"sentry_sdk.init(dsn="...", ...)(integration is auto-enabled when pydantic_ai is installed).AttributeError: type object 'ToolManager' has no attribute '_call_tool'during the patch in_patch_tool_execution().