safely merge empty tool call name case(streaming mode)#4588
Open
yxfengforever wants to merge 2 commits intospring-projects:mainfrom
Open
safely merge empty tool call name case(streaming mode)#4588yxfengforever wants to merge 2 commits intospring-projects:mainfrom
yxfengforever wants to merge 2 commits intospring-projects:mainfrom
Conversation
58b78b4 to
50698db
Compare
Signed-off-by: Feng Xie<yxloveforever@gmail.com> Signed-off-by: yxloveforever <yxloveforever@gmail.com>
Signed-off-by: Feng Xie<yxloveforever@gmail.com> Signed-off-by: yxloveforever <yxloveforever@gmail.com>
4bc0b1e to
9e61417
Compare
Contributor
|
Hi @yxfengforever , can you elaborate about the issue? What models/providers are generating tool call chunks without name? |
Author
|
The model i use is deepseek. Flux<ChatResponse> response = chatClient.prompt(ref.prompt)
Map.of("qam-user-id", headers.get("qam-user-id"))))
.stream().chatResponse();When it uses stream mode, then there are 2 tool calls return, of which one name is empty string. The expected response should be one tool call "weatherReport". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Feng Xieyxloveforever@gmail.com
Overview
The PR is to add a private method
safelyMergeAssistantMessageIfEmptyToolCallPresentprocesses and merges tool calls in an AssistantMessage, particularly handling cases where tool calls might have empty name or fragmented arguments due to streaming or other processing issues.Key Logic of
safelyMergeAssistantMessageIfEmptyToolCallPresentStringUtils.hasText(toolCall.name())check prevents invalid tool call exceptionsSafety Mechanism
StringUtils.hasText(toolCall.name())serves as a guard to:Result
Returns new AssistantMessage with merged tool calls, preserving original content, media, and metadata.