Pydantic AI integration erroneously considers `ToolRetryError` to be unhandled
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
Hi @JakobGM,
Thanks for the report and explanation. We will address this and keep you updated.
Hi @JakobGM,
We added an option to suppress these exceptions, and now report them as handled. Please initialize the integration as follows to stop seeing issues of this kind in your Sentry.
sentry_init(
...
integrations=[PydanticAIIntegration(handled_tool_call_exceptions=False)],
)