A2aAgent
public class A2aAgent extends AgentBase
io/agentscope/core/a2a/agent/A2aAgent.java:72–442A 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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgs | List<Msg> | 消息列表(类型 `List`)。The msgs. |
Mono<Msg>io/agentscope/core/a2a/agent/A2aAgent.java:115–132interrupt
public void interrupt()
请求中断当前执行。
Returns the interrupt.
io/agentscope/core/a2a/agent/A2aAgent.java:134–138interrupt
public void interrupt(Msg msg)
请求中断当前执行。
Performs the interrupt operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msg | Msg | 消息(类型 `Msg`)。The msg. |
io/agentscope/core/a2a/agent/A2aAgent.java:140–144doObserve
protected Mono<Void> doObserve(Msg msg)
执行观察操作。
Performs the do observe operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msg | Msg | 消息(类型 `Msg`)。The msg. |
Mono<Void>io/agentscope/core/a2a/agent/A2aAgent.java:146–150handleInterrupt
protected Mono<Msg> handleInterrupt(InterruptContext context, Msg... originalArgs)
处理中断。
Performs the handle interrupt operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
context | InterruptContext | 上下文(类型 `InterruptContext`)。The context. |
originalArgs varargs | Msg... | original 参数(类型 `Msg...`)。The original args. |
Mono<Msg>io/agentscope/core/a2a/agent/A2aAgent.java:152–172builder
public static Builder builder()
创建新的Builder实例用于A2aAgent。
Create a new Builder instance for A2aAgent.
Builderio/agentscope/core/a2a/agent/A2aAgent.java:179–181getMemory
public Memory getMemory()
获取记忆。
Returns the memory.
Memoryio/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
AgentBasegetAgentId, getName, getDescription, isCheckRunning, call, callInternal, interruptRunning, runLifecycle, callSerializationKey, call, call, doCall, doCall, addSystemHook, removeSystemHook, interrupt, checkInterruptedAsync, resetInterruptFlag, getInterruptFlag, getInterruptSource, getAgentState, beforeAgentExecution, afterAgentExecution, getHooks, addHook, removeHook, getSortedHooks, seedSystemMsg, stateForCall, consumeSystemMsgAfterPreCall, removeSubscribers, resetSubscribers, hasSubscribers, getSubscriberCount, observe, observe, stream, stream, stream, toString, CALL_SCOPE_KEY, RUNTIME_CONTEXT_KEY, SHUTDOWN_REQUEST_ID_KEY