@@ -46,16 +46,19 @@ default boolean isToolExecutionRequired(ChatOptions promptOptions, ChatResponse
4646
4747 /**
4848 * Determines if tool execution should be performed based on the prompt options and
49- * chat response and attempts .
49+ * chat response and toolExecutionIterations .
5050 * @param promptOptions The options from the prompt
5151 * @param chatResponse The response from the chat model
52- * @param attempts The number of attempts to execute the tool
52+ * @param toolExecutionIterations The number of toolExecutionIterations to execute the
53+ * tool
5354 * @return true if tool execution should be performed, false otherwise
5455 */
55- default boolean isToolExecutionRequired (ChatOptions promptOptions , ChatResponse chatResponse , int attempts ) {
56+ default boolean isToolExecutionRequired (ChatOptions promptOptions , ChatResponse chatResponse ,
57+ int toolExecutionIterations ) {
5658 Assert .notNull (promptOptions , "promptOptions cannot be null" );
5759 Assert .notNull (chatResponse , "chatResponse cannot be null" );
58- return this .isInternalToolExecutionEnabled (promptOptions , attempts ) && this .isToolCallResponse (chatResponse );
60+ return this .isInternalToolExecutionEnabled (promptOptions , toolExecutionIterations )
61+ && this .isToolCallResponse (chatResponse );
5962 }
6063
6164 /**
@@ -92,19 +95,20 @@ default boolean isInternalToolExecutionEnabled(ChatOptions chatOptions) {
9295 /**
9396 * Determines if tool execution should be performed by the Spring AI or by the client.
9497 * @param chatOptions The options from the chat
95- * @param attempts The number of attempts to execute the tool
98+ * @param toolExecutionIterations The number of toolExecutionIterations to execute the
99+ * tool
96100 * @return true if tool execution should be performed by Spring AI, false if it should
97101 * be performed by the client
98102 */
99- default boolean isInternalToolExecutionEnabled (ChatOptions chatOptions , int attempts ) {
103+ default boolean isInternalToolExecutionEnabled (ChatOptions chatOptions , int toolExecutionIterations ) {
100104 boolean internalToolExecutionEnabled = isInternalToolExecutionEnabled (chatOptions );
101105 if (!internalToolExecutionEnabled ) {
102106 return internalToolExecutionEnabled ;
103107 }
104108
105109 if (chatOptions instanceof ToolCallingChatOptions toolCallingChatOptions ) {
106110 return toolCallingChatOptions .getInternalToolExecutionMaxIterations () == null
107- || attempts <= toolCallingChatOptions .getInternalToolExecutionMaxIterations ();
111+ || toolExecutionIterations <= toolCallingChatOptions .getInternalToolExecutionMaxIterations ();
108112 }
109113 return internalToolExecutionEnabled ;
110114 }
0 commit comments