Skip to content

Commit c63341b

Browse files
committed
fix attempts check logical
Signed-off-by: lambochen <[email protected]>
1 parent e894e67 commit c63341b

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

spring-ai-model/src/main/java/org/springframework/ai/model/tool/ToolExecutionEligibilityChecker.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,13 @@ default boolean isInternalToolExecutionEnabled(ChatOptions chatOptions) {
9999
default boolean isInternalToolExecutionEnabled(ChatOptions chatOptions, int attempts) {
100100
boolean internalToolExecutionEnabled = isInternalToolExecutionEnabled(chatOptions);
101101
if (!internalToolExecutionEnabled) {
102-
return false;
102+
return internalToolExecutionEnabled;
103103
}
104104

105105
if (chatOptions instanceof ToolCallingChatOptions toolCallingChatOptions) {
106106
return toolCallingChatOptions.getInternalToolExecutionMaxAttempts() == null
107107
|| attempts <= toolCallingChatOptions.getInternalToolExecutionMaxAttempts();
108108
}
109-
else {
110-
internalToolExecutionEnabled = true;
111-
}
112109
return internalToolExecutionEnabled;
113110
}
114111

spring-ai-model/src/main/java/org/springframework/ai/model/tool/ToolExecutionEligibilityPredicate.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,13 @@ default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse
5656
default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse chatResponse, int attempts) {
5757
boolean isToolExecutionRequired = isToolExecutionRequired(promptOptions, chatResponse);
5858
if (!isToolExecutionRequired) {
59-
return true;
59+
return isToolExecutionRequired;
6060
}
6161

6262
if (promptOptions instanceof ToolCallingChatOptions toolCallingChatOptions) {
6363
return toolCallingChatOptions.getInternalToolExecutionMaxAttempts() == null
6464
|| attempts <= toolCallingChatOptions.getInternalToolExecutionMaxAttempts();
6565
}
66-
else {
67-
isToolExecutionRequired = true;
68-
}
6966
return isToolExecutionRequired;
7067
}
7168

0 commit comments

Comments
 (0)