AS AgentScopeAPI 手册 / API Reference

A2aAgent

public class A2aAgent extends AgentBase
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:72–442

A 2 a 智能体,支持智能体之间的发现、委派与协作。位于 io.agentscope.core.a2a.agent 包,继承自 AgentBase。核心成员包括 doCall、interrupt、doObserve、handleInterrupt、builder、getMemory。

The implementation of Agent for A2A(Agent2Agent).

Agent description should get from AgentCard. If AgentCard get failed, description will be default value from Agent#getDescription()

Example Usage:

` // Simple usage.
AgentCard agentCard = generateAgentCardByCode();
A2aAgent a2aAgent = A2aAgent.builder().name("remote-agent-name").agentCard(agentCard).build();

// Auto get AgentCard
AgentCardResolver agentCardResolver = new WellKnownAgentCardResolver("http://127.0.0.1:8080", "/.well-known/agent-card.json", Map.of());
A2aAgent a2aAgent = A2aAgent.builder().name("remote-agent-name").agentCardResolver(agentCardResolver).build();
`

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
A class in io.agentscope.core.a2a.agent that supports discovery, delegation and collaboration between agents.

方法摘要Method Summary

方法Method说明Description
protected Mono<Msg> doCall(List<Msg> msgs)
执行调用操作。
Performs the do call operation.
public void interrupt()
请求中断当前执行。
Returns the interrupt.
public void interrupt(Msg msg)
请求中断当前执行。
Performs the interrupt operation.
protected Mono<Void> doObserve(Msg msg)
执行观察操作。
Performs the do observe operation.
protected Mono<Msg> handleInterrupt(InterruptContext context, Msg... originalArgs)
处理中断。
Performs the handle interrupt operation.
public static Builder builder()
static
创建新的`Builder`实例用于`A2aAgent`。
Create a new `Builder` instance for `A2aAgent`.
public Memory getMemory()
获取记忆。
Returns the memory.

方法详情Method Detail

doCall

protected Mono<Msg> doCall(List<Msg> msgs)

执行调用操作。

Performs the do call operation.

参数Parameters
名称Name类型Type说明Description
msgsList<Msg>消息列表(类型 `List`)。The msgs.
返回Returns Mono<Msg>
返回Mono。Returns mono.
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:115–132

interrupt

public void interrupt()

请求中断当前执行。

Returns the interrupt.

源码Source io/agentscope/core/a2a/agent/A2aAgent.java:134–138

interrupt

public void interrupt(Msg msg)

请求中断当前执行。

Performs the interrupt operation.

参数Parameters
名称Name类型Type说明Description
msgMsg消息(类型 `Msg`)。The msg.
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:140–144

doObserve

protected Mono<Void> doObserve(Msg msg)

执行观察操作。

Performs the do observe operation.

参数Parameters
名称Name类型Type说明Description
msgMsg消息(类型 `Msg`)。The msg.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:146–150

handleInterrupt

protected Mono<Msg> handleInterrupt(InterruptContext context, Msg... originalArgs)

处理中断。

Performs the handle interrupt operation.

参数Parameters
名称Name类型Type说明Description
contextInterruptContext上下文(类型 `InterruptContext`)。The context.
originalArgs varargsMsg...original 参数(类型 `Msg...`)。The original args.
返回Returns Mono<Msg>
返回Mono。Returns mono.
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:152–172

builder

public static Builder builder()
static

创建新的Builder实例用于A2aAgent。

Create a new Builder instance for A2aAgent.

返回Returns Builder
返回当前实例,以支持链式调用。new builder instance
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:179–181

getMemory

public Memory getMemory()

获取记忆。

Returns the memory.

返回Returns Memory
返回记忆。Returns memory.
源码Source io/agentscope/core/a2a/agent/A2aAgent.java:183–185

嵌套类详情Nested Class Detail

Builder

public static class Builder

构建器,用于构建并配置目标实例。位于 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.

继承成员Inherited Members

继承自Methods inherited from Agent
继承自Methods inherited from CallableAgent
继承自Methods inherited from StreamableAgent
基于官方固定版本源码静态生成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.