sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Pydantic AI integration erroneously considers `ToolRetryError` to be unhandled

Open JakobGM opened this issue 6 days ago • 2 comments

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.47.0

Description

Pydantic AI's internal machinery raises pydantic_ai.exceptions.ToolRetryError when the output of a model does not satisfy the specified output schema. This exception is then caught further up the call-stack by Pydantic AI, which allows the LLM to be provided with the error and try again.

Sentry SDK's PydanticAIIntegration erroneously considers this exception to be unhandled, I think here in _patch_tool_execution(). This type of exception should probably be ignored by Sentry.

If you have access to our Sentry account for debugging purposes, you can take a look at this issue which should not have been an issue in the first place. If not, here are some screenshots:

Screenshots

Image Image

JakobGM avatar Dec 15 '25 09:12 JakobGM