AS AgentScopeAPI 手册 / API Reference

SchemaOnlyTool

public class SchemaOnlyTool extends ToolBase
源码Source 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.

参数Parameters
名称Name类型Type说明Description
schemaToolSchema模式定义(类型 `ToolSchema`)。The tool schema containing name, description, parameters, and strict mode
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if schema is null
源码Source io/agentscope/core/tool/SchemaOnlyTool.java:66–72

SchemaOnlyTool

public SchemaOnlyTool(String name, String description, Map<String, Object> parameters)

初始化 SchemaOnlyTool 实例。

Creates a new SchemaOnlyTool with the specified name, description, and parameters.

参数Parameters
名称Name类型Type说明Description
nameString工具名称。The tool name
descriptionString描述(类型 `String`)。The tool description
parametersMap<String, Object>工具参数模式。The tool parameters schema
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if name or description is null
源码Source io/agentscope/core/tool/SchemaOnlyTool.java:84–86

SchemaOnlyTool

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.

参数Parameters
名称Name类型Type说明Description
nameString工具名称。The tool name
descriptionString描述(类型 `String`)。The tool description
parametersMap<String, Object>工具参数模式。The tool parameters schema
strictBooleanstrict(类型 `Boolean`)。Whether the tool should use strict schema validation (null if unspecified)
抛出Throws
  • NullPointerException 可能抛出 `NullPointerException`。if name or description is null
源码Source io/agentscope/core/tool/SchemaOnlyTool.java:101–116

方法详情Method Detail

getStrict

public Boolean getStrict()

获取 getStrict。

Returns the strict.

返回Returns Boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/tool/SchemaOnlyTool.java:118–121

callAsync

public Mono<ToolResultBlock> callAsync(ToolCallParam param)

调用异步。

Throws a ToolSuspendException to signal that this tool requires external execution.

参数Parameters
名称Name类型Type说明Description
paramToolCallParam工具调用参数(已忽略)。The tool call parameters (ignored)
返回Returns Mono<ToolResultBlock>
返回Mono。Never returns normally
抛出Throws
  • ToolSuspendException 可能抛出 `ToolSuspendException`。always, to signal external execution is required
源码Source io/agentscope/core/tool/SchemaOnlyTool.java:133–136

继承成员Inherited Members

继承自Methods inherited from AgentTool
基于官方固定版本源码静态生成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.