Class ToolCallLimitExceededException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.vaadin.flow.component.ai.provider.ToolCallLimitExceededException
All Implemented Interfaces:
Serializable

public class ToolCallLimitExceededException extends RuntimeException
Signals that a turn was ended because the model requested more tool calls than allowed.

A model that keeps requesting tool calls instead of answering never ends the turn on its own, and each round costs another model call. Both built-in providers therefore end such a turn with this exception. LangChain4JLLMProvider runs the tool-calling loop itself and throws once the model has requested more calls to any one tool, or more tool calls in total, than LangChain4JLLMProvider.setMaxCallsPerTool(int) and LangChain4JLLMProvider.setMaxTotalToolCalls(int) allow; none of the tool calls of the refused round are executed, and the model is not called again. SpringAILLMProvider throws when Spring AI, which runs the loop itself, stops it at its own limits. You receive the exception as the error of the turn, through ResponseEvent.getError() in the ResponseListener and in AIController.onResponse.

The message names the limit that was exceeded, and the tool when the limit was a per-tool one, in the words of the framework that enforced it.

Since:
25.3
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • ToolCallLimitExceededException

      public ToolCallLimitExceededException(String message)
      Creates a new exception for a tool call limit exceeded during a turn. The built-in providers create it; the constructor is public so that you can construct one when unit testing a ResponseListener or an AIController, or throw it from a custom LLMProvider that bounds its own tool-calling loop.
      Parameters:
      message - a description of the limit that was exceeded