Class ToolCallLimitExceededException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.ai.model.tool.ToolCallLimitExceededException
All Implemented Interfaces:
Serializable

public class ToolCallLimitExceededException extends RuntimeException
Thrown by DefaultToolCallingManager when a configured tool call limit is exceeded and ToolCallLimitBehavior.THROW is in effect.

Carries the ToolExecutionResult assembled from whichever tool calls in the current batch already executed successfully before the limit was hit, so a caller can still produce a coherent response instead of discarding completed work.

Since:
2.0.1
Author:
Christian Tzolov
See Also:
  • Field Details

  • Constructor Details

    • ToolCallLimitExceededException

      public ToolCallLimitExceededException(@Nullable String toolName, int limit, ToolExecutionResult partialToolExecutionResult)
      Parameters:
      toolName - the name of the tool whose per-tool limit was exceeded, or null when the total per-turn limit was exceeded instead
      limit - the configured limit that was exceeded
      partialToolExecutionResult - the result assembled from the tool calls already executed in the current batch, including a synthesized error response for the call that exceeded the limit
  • Method Details

    • getToolName

      public @Nullable String getToolName()
      The name of the tool whose per-tool limit was exceeded, or null when the total per-turn limit was exceeded instead.
    • getLimit

      public int getLimit()
      The configured limit that was exceeded.
    • getPartialToolExecutionResult

      public ToolExecutionResult getPartialToolExecutionResult()
      The result assembled from the tool calls already executed in the current batch, including a synthesized error response for the call that exceeded the limit.
    • buildGeneration

      public Generation buildGeneration()
      Builds a single Generation representing this exception, so that a limit breach is never mistaken for one of several equally valid answers.

      The Generation's output is the breach message synthesized by DefaultToolCallingManager for the call that exceeded the limit. Any tool responses that completed successfully earlier in the same batch are attached under "partialToolResponses" instead of being emitted as separate, sibling generations, so completed work isn't discarded but also isn't confused with the error itself.