ToolSuspendException
public class ToolSuspendException extends RuntimeException
io/agentscope/core/tool/ToolSuspendException.java:40–69工具 Suspend 异常,表示执行过程中的错误。位于 io.agentscope.core.tool 包,继承自 RuntimeException。核心成员包括 getReason、ToolSuspendException。
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);
}
`
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public ToolSuspendException() | 创建新的ToolSuspendException 使用默认消息。 Creates a new ToolSuspendException with default message. |
public ToolSuspendException(String reason) | 创建新的ToolSuspendException 使用自定义推理。 Creates a new ToolSuspendException with a custom reason. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getReason() | 获取推理。 Gets the user-defined reason for suspension. |
构造器详情Constructor Detail
ToolSuspendException
public ToolSuspendException()
创建新的ToolSuspendException 使用默认消息。
Creates a new ToolSuspendException with default message.
io/agentscope/core/tool/ToolSuspendException.java:47–49ToolSuspendException
public ToolSuspendException(String reason)
创建新的ToolSuspendException 使用自定义推理。
Creates a new ToolSuspendException with a custom reason.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
reason | String | 原因(类型 `String`)。the reason for suspension, will be included in the pending ToolResultBlock |
io/agentscope/core/tool/ToolSuspendException.java:56–59方法详情Method Detail
getReason
public String getReason()
获取推理。
Gets the user-defined reason for suspension.
Stringio/agentscope/core/tool/ToolSuspendException.java:66–68