AS AgentScopeAPI 手册 / API Reference

SubAgentTool

public class SubAgentTool implements AgentTool
源码Source io/agentscope/core/tool/subagent/SubAgentTool.java:62–587

子智能体工具,封装可被智能体调用的能力。位于 io.agentscope.core.tool.subagent 包,实现 AgentTool。核心成员包括 getName、getDescription、getParameters、callAsync、SubAgentTool。

AgentTool implementation that wraps a sub-agent for multi-turn conversation.

This tool allows an agent to be called as a tool by other agents, supporting multi-turn conversation with session management. Each session maintains its own agent instance and state.

Thread safety is ensured by using SubAgentProvider to create a fresh agent instance for each new session.

The tool exposes two parameters:

  • session_id - Optional. Omit to start a new session, provide to continue an existing one.

  • message - Required. The message to send to the agent.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SubAgentTool(SubAgentProvider<?> agentProvider, SubAgentConfig config)
创建新的SubAgentTool。
Creates a new SubAgentTool.

方法摘要Method Summary

方法Method说明Description
public String getName()
获取名称。
Returns the name.
public String getDescription()
获取 `getDescription`。
Returns the description.
public Map<String, Object> getParameters()
获取参数。
Returns the parameters.
public Mono<ToolResultBlock> callAsync(ToolCallParam param)
调用异步。
Calls the async.

构造器详情Constructor Detail

SubAgentTool

public SubAgentTool(SubAgentProvider<?> agentProvider, SubAgentConfig config)

创建新的SubAgentTool。

Creates a new SubAgentTool.

参数Parameters
名称Name类型Type说明Description
agentProviderSubAgentProvider<?>智能体提供者(类型 `SubAgentProvider`)。Provider for creating agent instances
configSubAgentConfig用于工具的配置。Configuration for the tool
源码Source io/agentscope/core/tool/subagent/SubAgentTool.java:83–93

方法详情Method Detail

getName

public String getName()

获取名称。

Returns the name.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/tool/subagent/SubAgentTool.java:95–98

getDescription

public String getDescription()

获取 getDescription。

Returns the description.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/tool/subagent/SubAgentTool.java:100–103

getParameters

public Map<String, Object> getParameters()

获取参数。

Returns the parameters.

返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/core/tool/subagent/SubAgentTool.java:105–108

callAsync

public Mono<ToolResultBlock> callAsync(ToolCallParam param)

调用异步。

Calls the async.

参数Parameters
名称Name类型Type说明Description
paramToolCallParam参数(类型 `ToolCallParam`)。The param.
返回Returns Mono<ToolResultBlock>
返回Mono。Returns mono.
源码Source io/agentscope/core/tool/subagent/SubAgentTool.java:110–113

继承成员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.