AgentTool
public interface AgentTool
io/agentscope/core/tool/AgentTool.java:40–147定义智能体工具契约的接口。位于 io.agentscope.core.tool 包。核心成员包括 getName、getDescription、getParameters、getStrict、getOutputSchema、isReadOnly。
Interface for agent tools that can be called by models.
Agent tools are functions that AI agents can invoke to perform actions or retrieve information. They bridge the gap between the agent's reasoning and the external world.
Implementation Guidelines:
-
Tools should have clear, descriptive names
-
Descriptions should explain what the tool does and when to use it
-
Parameter schemas must follow JSON Schema format
-
All operations should be implemented asynchronously using Reactor Mono
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getName() | 获取名称的工具。 Gets the name of the tool. |
public String getDescription() | 获取 `getDescription`。 Gets the description of the tool. |
public Map<String, Object> getParameters() | 获取参数模式用于此工具,使用 JSON 模式格式。 Gets the parameters schema for this tool in JSON Schema format. |
default public Boolean getStrict()default | 获取 `getStrict`。 Gets strict mode configuration for this tool schema. |
default public Map<String, Object> getOutputSchema()default | 获取可选输出模式用于此工具,使用 JSON 模式格式。 Gets the optional output schema for this tool in JSON Schema format. |
default public boolean isReadOnly()default | 判断是否 `isReadOnly`。 Returns whether this tool performs only read operations and never mutates state. |
default public boolean isReturnDirect()default | 判断是否 `isReturnDirect`。 Whether this tool's result should be returned directly to the caller,
skipping the next reasoning iteration. |
public Mono<ToolResultBlock> callAsync(ToolCallParam param) | 调用异步。 Execute the tool with the given parameters (asynchronous). |
方法详情Method Detail
getName
public String getName()
获取名称的工具。
Gets the name of the tool.
Stringio/agentscope/core/tool/AgentTool.java:50getDescription
public String getDescription()
获取 getDescription。
Gets the description of the tool.
Stringio/agentscope/core/tool/AgentTool.java:60getParameters
public Map<String, Object> getParameters()
获取参数模式用于此工具,使用 JSON 模式格式。
Gets the parameters schema for this tool in JSON Schema format.
Map<String, Object>io/agentscope/core/tool/AgentTool.java:75getStrict
default public Boolean getStrict()
获取 getStrict。
Gets strict mode configuration for this tool schema.
Booleanio/agentscope/core/tool/AgentTool.java:86–88getOutputSchema
default public Map<String, Object> getOutputSchema()
获取可选输出模式用于此工具,使用 JSON 模式格式。
Gets the optional output schema for this tool in JSON Schema format.
Map<String, Object>io/agentscope/core/tool/AgentTool.java:99–101isReadOnly
default public boolean isReadOnly()
判断是否 isReadOnly。
Returns whether this tool performs only read operations and never mutates state.
booleanio/agentscope/core/tool/AgentTool.java:111–113isReturnDirect
default public boolean isReturnDirect()
判断是否 isReturnDirect。
Whether this tool's result should be returned directly to the caller, skipping the next reasoning iteration.
booleanio/agentscope/core/tool/AgentTool.java:128–130callAsync
public Mono<ToolResultBlock> callAsync(ToolCallParam param)
调用异步。
Execute the tool with the given parameters (asynchronous).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
param | ToolCallParam | 工具调用参数。The tool call parameters |
Mono<ToolResultBlock>io/agentscope/core/tool/AgentTool.java:146