AS AgentScopeAPI 手册 / API Reference

ToolSuspendException

public class ToolSuspendException extends RuntimeException
源码Source 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.

源码Source io/agentscope/core/tool/ToolSuspendException.java:47–49

ToolSuspendException

public ToolSuspendException(String reason)

创建新的ToolSuspendException 使用自定义推理。

Creates a new ToolSuspendException with a custom reason.

参数Parameters
名称Name类型Type说明Description
reasonString原因(类型 `String`)。the reason for suspension, will be included in the pending ToolResultBlock
源码Source io/agentscope/core/tool/ToolSuspendException.java:56–59

方法详情Method Detail

getReason

public String getReason()

获取推理。

Gets the user-defined reason for suspension.

返回Returns String
返回字符串结果。the reason, or null if not specified
源码Source io/agentscope/core/tool/ToolSuspendException.java:66–68
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.