Files
spring-ai/models
Mikhail Mazurkevich e6fbc28a5b [anthropic] fix issue #1370 with tool call duplication
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)

[anthropic] Replace `switchMap` -> `flatMap` to avoid cancellation of 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 <Mikhail.Mazurkevich@jetbrains.com>
2025-05-08 10:12:07 +01:00
..