类 SchemaOnlyTool
- 所有已实现的接口:
AgentTool
This class is used for registering external tools that will be executed outside the framework.
When a model returns a call to a SchemaOnlyTool, the framework will catch the
ToolSuspendException thrown by callAsync(ToolCallParam) and convert it to a
pending ToolResultBlock, then return a suspended message to the user.
The callAsync(ToolCallParam) method throws a ToolSuspendException
to signal that this tool requires external execution.
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));
- 另请参阅:
-
嵌套类概要
从类继承的嵌套类/接口 io.agentscope.core.tool.ToolBase
ToolBase.Builder -
字段概要
从类继承的字段 io.agentscope.core.tool.ToolBase
dangerousDirectories, dangerousFiles -
构造器概要
构造器构造器说明SchemaOnlyTool(ToolSchema schema) Creates a new SchemaOnlyTool from a ToolSchema.Creates a new SchemaOnlyTool with the specified name, description, and parameters.Creates a new SchemaOnlyTool with the specified name, description, parameters, and strict mode configuration. -
方法概要
修饰符和类型方法说明reactor.core.publisher.Mono<ToolResultBlock> callAsync(ToolCallParam param) Throws a ToolSuspendException to signal that this tool requires external execution.Gets strict mode configuration for this tool schema.从类继承的方法 io.agentscope.core.tool.ToolBase
builder, checkPermissions, generateSuggestions, getDescription, getMcpName, getName, getParameters, isConcurrencySafe, isDangerousPath, isExternalTool, isMcp, isReadOnly, isStateInjected, matchRule从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.tool.AgentTool
getOutputSchema
-
构造器详细资料
-
SchemaOnlyTool
Creates a new SchemaOnlyTool from a ToolSchema.- 参数:
schema- The tool schema containing name, description, parameters, and strict mode- 抛出:
NullPointerException- if schema is null
-
SchemaOnlyTool
Creates a new SchemaOnlyTool with the specified name, description, and parameters.Strict mode is set to null (unspecified).
- 参数:
name- The tool namedescription- The tool descriptionparameters- The tool parameters schema- 抛出:
NullPointerException- if name or description is null
-
SchemaOnlyTool
public SchemaOnlyTool(String name, String description, Map<String, Object> parameters, Boolean strict) Creates a new SchemaOnlyTool with the specified name, description, parameters, and strict mode configuration.The parameters map is defensively copied to prevent external mutations from affecting the tool's internal state.
- 参数:
name- The tool namedescription- The tool descriptionparameters- The tool parameters schemastrict- Whether the tool should use strict schema validation (null if unspecified)- 抛出:
NullPointerException- if name or description is null
-
-
方法详细资料
-
getStrict
从接口复制的说明:AgentToolGets strict mode configuration for this tool schema.When strict mode is enabled, compatible model providers are expected to enforce stricter adherence to the tool parameter schema. Returning
nullmeans no explicit strict mode preference is provided.- 返回:
- strict mode value (
true/false) ornullwhen unspecified
-
callAsync
Throws a ToolSuspendException to signal that this tool requires external execution.The framework will catch this exception and convert it to a pending
ToolResultBlock. The agent will then return a suspended message withGenerateReason.TOOL_SUSPENDEDcontaining the tool use blocks that need external execution.- 指定者:
callAsync在接口中AgentTool- 覆盖:
callAsync在类中ToolBase- 参数:
param- The tool call parameters (ignored)- 返回:
- Never returns normally
- 抛出:
ToolSuspendException- always, to signal external execution is required
-