SchemaOnlyTool
public class SchemaOnlyTool extends ToolBase
io/agentscope/core/tool/SchemaOnlyTool.java:56–137模式 Only 工具,封装可被智能体调用的能力。位于 io.agentscope.core.tool 包,继承自 ToolBase。核心成员包括 getStrict、callAsync、SchemaOnlyTool。
An external tool implementation that only contains schema definition without execution logic.
This class is used for registering external tools that will be executed outside the framework.
When a model returns a call to a SchemaOnlyTool, Toolkit surfaces the call as a pending
ToolResultBlock, then the agent returns a suspended message to the user.
The #callAsync(ToolCallParam) method still throws a ToolSuspendException
for direct invocations outside the Toolkit execution path.
Example usage:
`ToolSchema schema = ToolSchema.builder()
.name("query_database")
.description("Query external database")
.parameters(Map.of(
"type", "object",
"properties", Map.of("sql", Map.of("type", "string")),
"required", List.of("sql")
))
.build();
toolkit.registerSchema(schema);
// Or: toolkit.registerAgentTool(new SchemaOnlyTool(schema));
`
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public SchemaOnlyTool(ToolSchema schema) | 创建新的SchemaOnlyTool 来自 ToolSchema。 Creates a new SchemaOnlyTool from a ToolSchema. |
public SchemaOnlyTool(String name, String description, Map<String, Object> parameters) | 初始化 `SchemaOnlyTool` 实例。 Creates a new SchemaOnlyTool with the specified name, description, and parameters. |
public SchemaOnlyTool(String name, String description, Map<String, Object> parameters, Boolean strict) | 初始化 `SchemaOnlyTool` 实例。 Creates a new SchemaOnlyTool with the specified name, description, parameters, and strict
mode configuration. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Boolean getStrict() | 获取 `getStrict`。 Returns the strict. |
public Mono<ToolResultBlock> callAsync(ToolCallParam param) | 调用异步。 Throws a ToolSuspendException to signal that this tool requires external execution. |
构造器详情Constructor Detail
SchemaOnlyTool
public SchemaOnlyTool(ToolSchema schema)
创建新的SchemaOnlyTool 来自 ToolSchema。
Creates a new SchemaOnlyTool from a ToolSchema.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
schema | ToolSchema | 模式定义(类型 `ToolSchema`)。The tool schema containing name, description, parameters, and strict mode |
NullPointerException可能抛出 `NullPointerException`。if schema is null
io/agentscope/core/tool/SchemaOnlyTool.java:66–72SchemaOnlyTool
public SchemaOnlyTool(String name, String description, Map<String, Object> parameters)
初始化 SchemaOnlyTool 实例。
Creates a new SchemaOnlyTool with the specified name, description, and parameters.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 工具名称。The tool name |
description | String | 描述(类型 `String`)。The tool description |
parameters | Map<String, Object> | 工具参数模式。The tool parameters schema |
NullPointerException可能抛出 `NullPointerException`。if name or description is null
io/agentscope/core/tool/SchemaOnlyTool.java:84–86SchemaOnlyTool
public SchemaOnlyTool(String name, String description, Map<String, Object> parameters, Boolean strict)
初始化 SchemaOnlyTool 实例。
Creates a new SchemaOnlyTool with the specified name, description, parameters, and strict mode configuration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 工具名称。The tool name |
description | String | 描述(类型 `String`)。The tool description |
parameters | Map<String, Object> | 工具参数模式。The tool parameters schema |
strict | Boolean | strict(类型 `Boolean`)。Whether the tool should use strict schema validation (null if unspecified) |
NullPointerException可能抛出 `NullPointerException`。if name or description is null
io/agentscope/core/tool/SchemaOnlyTool.java:101–116方法详情Method Detail
getStrict
public Boolean getStrict()
获取 getStrict。
Returns the strict.
Booleanio/agentscope/core/tool/SchemaOnlyTool.java:118–121callAsync
public Mono<ToolResultBlock> callAsync(ToolCallParam param)
调用异步。
Throws a ToolSuspendException to signal that this tool requires external execution.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
param | ToolCallParam | 工具调用参数(已忽略)。The tool call parameters (ignored) |
Mono<ToolResultBlock>ToolSuspendException可能抛出 `ToolSuspendException`。always, to signal external execution is required
io/agentscope/core/tool/SchemaOnlyTool.java:133–136