Skip to content

Conversation

@sunyuhan1998
Copy link
Contributor

@sunyuhan1998 sunyuhan1998 commented Sep 26, 2025

As mentioned in the issue, the current implementation of the mergeToolUseEvents method in StreamHelper lacks robustness and does not properly handle cases where previousEvent is not of type ToolUseAggregationEvent. This PR addresses that issue.

All the changes introduced by this PR:

  1. Improved the mergeToolUseEvents method in StreamHelper to skip merging when previousEvent is not a ToolUseAggregationEvent.
  2. Enhanced StreamHelperTests to improve test coverage.
  3. A new issue was uncovered via unit tests: the eventToChatCompletionResponse method in StreamHelper did not handle the thinkingBlock.signature() property. This PR also fixes that issue.

Fixes #4472

…hod in `StreamHelper` to enhance robustness when `previousEvent` is not a `ToolUseAggregationEvent`;

2. Fixed an issue in the `eventToChatCompletionResponse` method of `StreamHelper` where `thinkingBlock.signature()` was not being handled;
3. Improved `StreamHelperTests` to increase test coverage

Signed-off-by: Sun Yuhan <[email protected]>
Signed-off-by: Sun Yuhan <[email protected]>
@ilayaperumalg ilayaperumalg self-assigned this Sep 26, 2025
@ilayaperumalg ilayaperumalg added this to the 1.1.0.M3 milestone Sep 26, 2025
@ilayaperumalg ilayaperumalg added the bug Something isn't working label Sep 26, 2025
# Conflicts:
#	models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api/StreamHelperTests.java
@ilayaperumalg
Copy link
Member

@sunyuhan1998 Thanks for fixing this bug.

@ilayaperumalg
Copy link
Member

LGTM, rebased and merged as 9907b2c

@ilayaperumalg
Copy link
Member

Cherry-picked, and merged into 1.0.x as 6ced885

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants