Skip to content

Commit b737af9

Browse files
committed
fix ut for org.springframework.ai.model.tool.ToolExecutionEligibilityChecker#isLimitExceeded
Signed-off-by: lambochen <[email protected]>
1 parent 86ba656 commit b737af9

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ default boolean isInternalToolExecutionEnabled(ChatOptions chatOptions, int tool
117117
*/
118118
default boolean isLimitExceeded(ChatOptions promptOptions, int toolExecutionIterations) {
119119
if (promptOptions instanceof ToolCallingChatOptions toolCallingChatOptions) {
120-
return toolCallingChatOptions.getInternalToolExecutionMaxIterations() == null
121-
|| toolExecutionIterations <= toolCallingChatOptions.getInternalToolExecutionMaxIterations();
120+
return toolCallingChatOptions.getInternalToolExecutionMaxIterations() != null
121+
&& toolExecutionIterations > toolCallingChatOptions.getInternalToolExecutionMaxIterations();
122122
}
123123

124124
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse
7171
*/
7272
default boolean isLimitExceeded(ChatOptions promptOptions, int toolExecutionIterations) {
7373
if (promptOptions instanceof ToolCallingChatOptions toolCallingChatOptions) {
74-
return toolCallingChatOptions.getInternalToolExecutionMaxIterations() == null
75-
|| toolExecutionIterations <= toolCallingChatOptions.getInternalToolExecutionMaxIterations();
74+
return toolCallingChatOptions.getInternalToolExecutionMaxIterations() != null
75+
&& toolExecutionIterations > toolCallingChatOptions.getInternalToolExecutionMaxIterations();
7676
}
7777

7878
return false;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2023-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ai.model.tool;
18+
19+
/**
20+
* @author lambochen
21+
*/
22+
public interface ToolExecutionRequest {
23+
24+
}

0 commit comments

Comments
 (0)