-
Notifications
You must be signed in to change notification settings - Fork 512
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
Fix Anthropic integration when using tool calls #3615
Conversation
Handles InputJsonDelta for anthropic >= 0.27.0 which broke tool calling in streams.
@antonpirker is this something you might have some time to look at 😅 |
Will have a look at on Thursday |
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #3615 +/- ##
=======================================
Coverage 84.31% 84.32%
=======================================
Files 133 133
Lines 14056 14063 +7
Branches 2377 2379 +2
=======================================
+ Hits 11851 11858 +7
Misses 1471 1471
Partials 734 734
|
…rded InputJsonDelta
Hey @kwnath ! Thanks again for your contribution! I finally had some time to look at your PR. I took the liberty to change some stuff to bring it over the finish line. When all the tests have passed, this is ready to be merged! |
@antonpirker Looks like the codecov/patch is stuck 😅 |
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.
Looks good!
@kwnath your fix has been released in this version: https://pypi.org/project/sentry-sdk/2.17.0/ |
Description
If you've initialized Sentry with Anthropic integration, streaming responses with tool calls fail.
The reason is quite simple, the API introduced a new data model for a
ContentBlockDeltaEvent
. This new refactor was made in0.27.0
because json was needed to be streamed back (so arguments were returned as json for tool calls, I think this was the initial reason). This introduced a new data type InputJsonDelta that had it's contents inpartial_json
instead of what is currently supportedtext
(reference).And you'll find in the original integration we try to get the
text
if the type is acontent_block_delta
, this doesn't exist if you're doing any sort of tool calling with streaming. This doesn't fail however if you turn off streaming.More info on reproduction steps here
Side notes
ContentBlockDeltaEvent
, there are likely other incompatible areas but this is the most breaking one. (I can add a few follow up PR's)