-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(pydantic-ai): Add error handling to agent execution #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swallowed exceptions prevent sentry_sdk.capture_exception from firing
High Severity
The new
except Exception as eblock catches and prints the error but never re-raises it. When thecauseAPIErrorflag is set,base.python.njkwraps themain()call in its own try-except that callssentry_sdk.capture_exception(e)— but the exception is now silently swallowed insidemain(), so it never propagates. This means Sentry never captures the exception, breaking the error-handling test scenarios that depend on it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is entirely accurate as I verified during testing that an error span is being returned from the Python SDK (and not being swallowed as Cursor is saying here) as a result of the generic exception thrown, and is being asserted correctly within the testing framework (example below from a test run):
{ trace_id: '25a8c19c306a42a2b1bd22b34daa3e84', span_id: '85d009fd8743fdb6', parent_span_id: '905cfffa695c1f38', same_process_as_parent: true, op: 'gen_ai.execute_tool', description: 'execute_tool read_file', start_timestamp: '2026-03-06T16:13:37.239475Z', timestamp: '2026-03-06T16:13:37.240453Z', origin: 'auto.ai.pydantic_ai', status: 'internal_error', tags: { status: 'internal_error' }, data: { 'thread.id': '8372809984', 'thread.name': 'MainThread', 'gen_ai.operation.name': 'execute_tool', 'gen_ai.tool.type': 'function', 'gen_ai.tool.name': 'read_file', 'gen_ai.agent.name': 'file_assistant', 'gen_ai.tool.input': '{"path": "/nonexistent/file.txt"}' } }