-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
Description
Bug description
Inside org.springframework.ai.openai.api.OpenAiStreamFunctionCallingHelper at line 114:
if (currentToolCall.id() != null) { //HERE
if (lastPreviousTooCall != null) {
toolCalls.add(lastPreviousTooCall);
}
toolCalls.add(currentToolCall);
}
else {
toolCalls.add(merge(lastPreviousTooCall, currentToolCall));
}
The current logic for merging ToolCallChunk streams assumes that the tool call ID will be null. However, some API implementations, such as Aliyun Model Studio, return an empty string ("") instead.
This discrepancy causes the merge logic to fail, preventing partial tool call chunks from being correctly assembled into a single function call.
A simple fix is to change the null check to a more robust blank string check (e.g., StringUtils.isBlank()). This will resolve the issue with Aliyun models and improve the overall compatibility of Spring AI with different API providers.