-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[anthropic] fix issue #1370 with tool call duplication #2670
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
base: main
Are you sure you want to change the base?
[anthropic] fix issue #1370 with tool call duplication #2670
Conversation
de87a81
to
15dfed8
Compare
@mmazurkevich Thanks for debugging and submitting the PR to fix the issue. |
Without this fix during the stream event handling when `EventType.MESSAGE_STOP` occurs, the latest content block was resent again and it caused to the additional tool call(if it was the latest event) Signed-off-by: Mikhail Mazurkevich <[email protected]>
15dfed8
to
f3adcae
Compare
@ilayaperumalg I've updated the formatting and force-pushed the changes because of the failed GH Action |
@mmazurkevich With this change, some of the stream+toolcalling tests are failing: AnthropicChatClientIT#streamFunctionCallTest Could you check? |
… the original request Previously, internalStream used switchMap to process ChatCompletionResponses, which caused the active stream (including potential recursive calls) to be canceled whenever a new response arrived. This led to incomplete processing of streaming tool calls and unexpected behavior when handling tool_use events. Replaced switchMap with flatMap to ensure that each response is fully processed without being interrupted, allowing recursive internalStream calls to complete as expected. Without this fix during the stream event handling when `EventType.MESSAGE_STOP` occurs, the latest content block was resent again and it caused to the additional tool call(if it was the latest event) Signed-off-by: Mikhail Mazurkevich <[email protected]>
@ilayaperumalg thank you for the ping. The failed test highlighted the problem that was in the code even before the change. Previously, The fix has been pushed. Also, I've run all 50 tests locally with my own ANTHROPIC_API_KEY looks like all of them passed |
@mmazurkevich Thank you so much for the quick response, fixing the issue and verifying all the tests! I will get this merged soon. |
Without this fix during the stream event handling when
EventType.MESSAGE_STOP
occurs, the latest content block was resent again and it caused to the additional tool call(if it was the latest event)Also I've described the root cause in the comment to the issue