类 ToolSuspendException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.agentscope.core.tool.ToolSuspendException
- 所有已实现的接口:
Serializable
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:
- Convert the exception to a pending
ToolResultBlock - Return a suspended message to the user with
GenerateReason.TOOL_SUSPENDED - 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);
}
- 另请参阅:
-
构造器概要
构造器构造器说明Creates a new ToolSuspendException with default message.ToolSuspendException(String reason) Creates a new ToolSuspendException with a custom reason. -
方法概要
-
构造器详细资料
-
ToolSuspendException
public ToolSuspendException()Creates a new ToolSuspendException with default message. -
ToolSuspendException
Creates a new ToolSuspendException with a custom reason.- 参数:
reason- the reason for suspension, will be included in the pending ToolResultBlock
-
-
方法详细资料
-
getReason
Gets the user-defined reason for suspension.- 返回:
- the reason, or null if not specified
-