AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:289–441

构建器,用于构建并配置目标实例。位于 io.agentscope.core.a2a.agent 包。核心成员包括 name、agentCard、agentCardResolver、a2aAgentConfig、memory、checkRunning。

A class in io.agentscope.core.a2a.agent that supports discovery, delegation and collaboration between agents. Declared in io.agentscope.core.a2a.agent.

方法摘要Method Summary

方法Method说明Description
public Builder name(String name)
设置名称的A2aAgent。
Set the name of the A2aAgent.
public Builder agentCard(AgentCard agentCard)
设置`AgentCard`用于 A2aAgent。
Set the `AgentCard` for the A2aAgent.
public Builder agentCardResolver(AgentCardResolver agentCardResolver)
设置`AgentCardResolver`用于 A2aAgent。
Set the `AgentCardResolver` for the A2aAgent.
public Builder a2aAgentConfig(A2aAgentConfig a2aAgentConfig)
设置`A2aAgentConfig`用于 A2aAgent。
Set the `A2aAgentConfig` for the A2aAgent.
public Builder memory(Memory memory)
设置`Memory`用于 A2aAgent。
Set the `Memory` for the A2aAgent.
public Builder checkRunning(boolean checkRunning)
设置检查运行中。
Set whether to check the running status of the A2aAgent.
public Builder hook(Hook hook)
设置钩子。
Add a `Hook` to the A2aAgent.
public Builder hooks(List<Hook> hooks)
设置该配置项。
Add multiple `Hook`s to the A2aAgent.
public A2aAgent build()
构建A2aAgent 实例。
Build the A2aAgent instance.

方法详情Method Detail

name

public Builder name(String name)

设置名称的A2aAgent。

Set the name of the A2aAgent.

参数Parameters
名称Name类型Type说明Description
nameString名称到设置。the name to set
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:309–312

agentCard

public Builder agentCard(AgentCard agentCard)

设置AgentCard用于 A2aAgent。

Set the AgentCard for the A2aAgent.

另见See also @see #agentCardResolver(AgentCardResolver)
参数Parameters
名称Name类型Type说明Description
agentCardAgentCardAgentCard 到设置。the AgentCard to set
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:323–325

agentCardResolver

public Builder agentCardResolver(AgentCardResolver agentCardResolver)

设置AgentCardResolver用于 A2aAgent。

Set the AgentCardResolver for the A2aAgent.

参数Parameters
名称Name类型Type说明Description
agentCardResolverAgentCardResolver智能体卡片解析器(类型 `AgentCardResolver`)。the AgentCardResolver to set, null value will be ignored.
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:336–349

a2aAgentConfig

public Builder a2aAgentConfig(A2aAgentConfig a2aAgentConfig)

设置A2aAgentConfig用于 A2aAgent。

Set the A2aAgentConfig for the A2aAgent.

参数Parameters
名称Name类型Type说明Description
a2aAgentConfigA2aAgentConfigA2aAgentConfig 到设置。the A2aAgentConfig to set
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:357–360

memory

public Builder memory(Memory memory)

设置Memory用于 A2aAgent。

Set the Memory for the A2aAgent.

参数Parameters
名称Name类型Type说明Description
memoryMemory记忆到设置。the Memory to set
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:370–373

checkRunning

public Builder checkRunning(boolean checkRunning)

设置检查运行中。

Set whether to check the running status of the A2aAgent.

参数Parameters
名称Name类型Type说明Description
checkRunningboolean检查运行中(类型 `boolean`)。true to check the running status, false to ignore
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:383–386

hook

public Builder hook(Hook hook)

设置钩子。

Add a Hook to the A2aAgent.

参数Parameters
名称Name类型Type说明Description
hookHook钩子到添加。the Hook to add
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:394–397

hooks

public Builder hooks(List<Hook> hooks)

设置该配置项。

Add multiple Hooks to the A2aAgent.

参数Parameters
名称Name类型Type说明Description
hooksList<Hook>hooks(类型 `List`)。the list of Hooks to add
返回Returns Builder
返回当前实例,以支持链式调用。the current Builder instance for method chaining
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:405–408

build

public A2aAgent build()

构建A2aAgent 实例。

Build the A2aAgent instance.

返回Returns A2aAgent
内置 A2aAgent 实例。the built A2aAgent instance
抛出Throws
  • IllegalArgumentException 当if agentCardResolver是不设置时抛出 `IllegalArgumentException`。if agentCardResolver is not set
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:416–431
基于官方固定版本源码静态生成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.