类 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:
// Register an external tool using ToolSchema
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));
- 另请参阅:
-
构造器概要
构造器构造器说明SchemaOnlyTool(ToolSchema schema) Creates a new SchemaOnlyTool from a ToolSchema.Creates a new SchemaOnlyTool with the specified name, description, and parameters. -
方法概要
修饰符和类型方法说明reactor.core.publisher.Mono<ToolResultBlock> callAsync(ToolCallParam param) Throws a ToolSuspendException to signal that this tool requires external execution.Gets the description of the tool.getName()Gets the name of the tool.Gets the parameters schema for this tool in JSON Schema format.从类继承的方法 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, and parameters- 抛出:
NullPointerException- if schema is null
-
SchemaOnlyTool
Creates a new SchemaOnlyTool with the specified name, description, and parameters.- 参数:
name- The tool namedescription- The tool descriptionparameters- The tool parameters schema- 抛出:
NullPointerException- if name or description is null
-
-
方法详细资料
-
getName
从接口复制的说明:AgentToolGets the name of the tool.The name should be unique within a toolkit and follow snake_case convention for compatibility with various LLM providers.
-
getDescription
从接口复制的说明:AgentToolGets the description of the tool.The description should clearly explain what the tool does, when it should be used, and what kind of results it returns. This helps the LLM decide when to invoke the tool.
- 指定者:
getDescription在接口中AgentTool- 返回:
- The tool description (never null)
-
getParameters
从接口复制的说明:AgentToolGets the parameters schema for this tool in JSON Schema format.The schema defines the structure of the input parameters that this tool accepts. It should include:
- type: "object"
- properties: Map of parameter names to their schemas
- required: List of required parameter names
- 指定者:
getParameters在接口中AgentTool- 返回:
- Map representing the JSON Schema for tool parameters (never null)
-
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- 参数:
param- The tool call parameters (ignored)- 返回:
- Never returns normally
- 抛出:
ToolSuspendException- always, to signal external execution is required
-