AS AgentScopeAPI 手册 / API Reference

AgentTool

public interface AgentTool
源码Source 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.

返回Returns String
返回字符串结果。The tool name (never null)
源码Source io/agentscope/core/tool/AgentTool.java:50

getDescription

public String getDescription()

获取 getDescription。

Gets the description of the tool.

返回Returns String
返回字符串结果。The tool description (never null)
源码Source io/agentscope/core/tool/AgentTool.java:60

getParameters

public Map<String, Object> getParameters()

获取参数模式用于此工具,使用 JSON 模式格式。

Gets the parameters schema for this tool in JSON Schema format.

返回Returns Map<String, Object>
返回映射。Map representing the JSON Schema for tool parameters (never null)
源码Source io/agentscope/core/tool/AgentTool.java:75

getStrict

default public Boolean getStrict()
default

获取 getStrict。

Gets strict mode configuration for this tool schema.

返回Returns Boolean
返回布尔值,表示判断结果。strict mode value (`true`/`false`) or `null` when unspecified
源码Source io/agentscope/core/tool/AgentTool.java:86–88

getOutputSchema

default public Map<String, Object> getOutputSchema()
default

获取可选输出模式用于此工具,使用 JSON 模式格式。

Gets the optional output schema for this tool in JSON Schema format.

返回Returns Map<String, Object>
返回映射。Map representing the JSON Schema for tool outputs, or null if unsupported
源码Source io/agentscope/core/tool/AgentTool.java:99–101

isReadOnly

default public boolean isReadOnly()
default

判断是否 isReadOnly。

Returns whether this tool performs only read operations and never mutates state.

返回Returns boolean
返回布尔值,表示判断结果。`true` if the tool is read-only; `false` by default
源码Source io/agentscope/core/tool/AgentTool.java:111–113

isReturnDirect

default public boolean isReturnDirect()
default

判断是否 isReturnDirect。

Whether this tool's result should be returned directly to the caller, skipping the next reasoning iteration.

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

callAsync

public Mono<ToolResultBlock> callAsync(ToolCallParam param)

调用异步。

Execute the tool with the given parameters (asynchronous).

参数Parameters
名称Name类型Type说明Description
paramToolCallParam工具调用参数。The tool call parameters
返回Returns Mono<ToolResultBlock>
返回Mono。Mono containing ToolResultBlock
源码Source io/agentscope/core/tool/AgentTool.java:146
基于官方固定版本源码静态生成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.