Class ToolCallLimitExceededException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.ai.model.tool.ToolCallLimitExceededException
- All Implemented Interfaces:
Serializable
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringGeneration.getMetadata()finish reason set on theGenerationbuilt bybuildGeneration(), distinguishing a forcibly aborted turn from a regularreturnDirectcompletion.static final StringChatGenerationMetadatakey under which theToolResponseMessage.ToolResponses that completed successfully in the current batch before the limit was hit are attached to theGenerationbuilt bybuildGeneration(). -
Constructor Summary
ConstructorsConstructorDescriptionToolCallLimitExceededException(@Nullable String toolName, int limit, ToolExecutionResult partialToolExecutionResult) -
Method Summary
Modifier and TypeMethodDescriptionBuilds a singleGenerationrepresenting this exception, so that a limit breach is never mistaken for one of several equally valid answers.intgetLimit()The configured limit that was exceeded.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.@Nullable StringThe name of the tool whose per-tool limit was exceeded, ornullwhen the total per-turn limit was exceeded instead.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
FINISH_REASON
Generation.getMetadata()finish reason set on theGenerationbuilt bybuildGeneration(), distinguishing a forcibly aborted turn from a regularreturnDirectcompletion.- See Also:
-
METADATA_PARTIAL_TOOL_RESPONSES
ChatGenerationMetadatakey under which theToolResponseMessage.ToolResponses that completed successfully in the current batch before the limit was hit are attached to theGenerationbuilt bybuildGeneration(). Keeping them in metadata - rather than as separate, siblingGenerations - avoids mixing successful tool output with the error message as if they were equally valid alternative answers.- See Also:
-
-
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, ornullwhen the total per-turn limit was exceeded insteadlimit- the configured limit that was exceededpartialToolExecutionResult- 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
The name of the tool whose per-tool limit was exceeded, ornullwhen the total per-turn limit was exceeded instead. -
getLimit
public int getLimit()The configured limit that was exceeded. -
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
Builds a singleGenerationrepresenting 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 byDefaultToolCallingManagerfor 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.
-