类 ToolSuspendException

所有已实现的接口:
Serializable

public class ToolSuspendException extends RuntimeException
Exception thrown to signal that a tool execution should be suspended and handled externally.

This exception is used by tools that require external execution (e.g., tools registered via schema-only registration). When thrown, the framework will:

  1. Convert the exception to a pending ToolResultBlock
  2. Return a suspended message to the user with GenerateReason.TOOL_SUSPENDED
  3. Wait for the user to provide the tool execution result

Example usage in a custom tool:


 @Tool(name = "external_api", description = "Call external API")
 public ToolResultBlock callExternalApi(@ToolParam(name = "url") String url) {
     // Signal that this tool needs external execution
     throw new ToolSuspendException("Requires external API call to: " + url);
 }
 
另请参阅:
  • 构造器详细资料

    • ToolSuspendException

      public ToolSuspendException()
      Creates a new ToolSuspendException with default message.
    • ToolSuspendException

      public ToolSuspendException(String reason)
      Creates a new ToolSuspendException with a custom reason.
      参数:
      reason - the reason for suspension, will be included in the pending ToolResultBlock
  • 方法详细资料

    • getReason

      public String getReason()
      Gets the user-defined reason for suspension.
      返回:
      the reason, or null if not specified