-
Notifications
You must be signed in to change notification settings - Fork 571
feat(integration): pydantic-ai: properly report token usage and response model for invoke_agent spans #5153
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
feat(integration): pydantic-ai: properly report token usage and response model for invoke_agent spans #5153
Conversation
…nse model for invoke_agent spans
sentrivana
left a comment
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.
Thanks, looks good to me, see one comment.
Side question: would you say this is more of a feature or a bugfix? We have a fancy new changelog generation system and I want to tag this properly 😄
| # Set token usage data if available | ||
| if hasattr(result, "usage") and callable(result.usage): | ||
| try: | ||
| usage = result.usage() |
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.
Can calling usage() have any (side-)effects that we wouldn't want to trigger?
I'm thinking something in the vein of extra DB access, API request, etc. We had a similar case in Django where we were trying to get the connection params to the DB and in some users' case that actually resulted in some expensive operations being performed.
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.
No, this literally has the comment "should be a property". It is just an accessor for a nested field.
It adds new fields, but those were kind of expected. So we can consider this a bugfix |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #5153 +/- ##
=======================================
Coverage 83.97% 83.98%
=======================================
Files 180 181 +1
Lines 18222 18241 +19
Branches 3235 3239 +4
=======================================
+ Hits 15302 15319 +17
Misses 1929 1929
- Partials 991 993 +2
|
Issues
Closes https://linear.app/getsentry/issue/TET-1458/py-pydantic-ai-attributes-missing