类:RemoteA2AAgent
java.lang.Object
com.google.adk.workflow.BaseNode
com.google.adk.agents.BaseAgent
com.google.adk.a2a.agent.RemoteA2AAgent
- All Implemented Interfaces:
Node
该代理通过 A2A 客户端与远程的 A2A 代理进行通信。
可以通过直接提供相应的参数来指定远程代理。 AgentCard “致开发者:”
或者,该问题可以通过提供的 A2A 客户端自动解决。
该代理的主要职责包括:
- 代理卡(Agent card)的分辨率处理及验证
- 将 ADK 会话历史事件转换为 A2A 请求)
Message) - 处理来自 A2A 客户端的流式(streaming)和非流式(non-streaming)响应
- 将流式响应数据块缓冲并汇总到 ADK 中
Events - 将 A2A 客户端响应转换回 ADK 格式
-
嵌套类概述
Nested ClassesModifier and TypeClassDescriptionstatic class当代理卡无法被识别(即无法找到对应的代理信息)时,会抛出异常。static class“Builder for”是一个用于描述某种构建工具或框架的术语。它通常表示该工具/框架用于帮助开发者或系统管理员快速、高效地创建或构建特定类型的应用程序、系统或组件。例如:“Builder for Web Applications”(用于构建Web应用程序的工具)或“Builder for Cloud Services”(用于构建云服务的工具)。RemoteA2AAgent.static class当发生类型错误时,会抛出异常。 -
方法概述
Modifier and TypeMethodDescriptionstatic RemoteA2AAgent.Builderbuilder()booleanprotected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext) 与特定代理(Agent)相关的异步逻辑(Agent-specific asynchronous logic)。protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext) 与特定代理相关的同步逻辑(Agent-specific synchronous logic)。当该代理被用作工具时,该方法会返回该工具的来源信息。Methods inherited from class BaseAgent
afterAgentCallback, beforeAgentCallback, canonicalAfterAgentCallbacks, canonicalBeforeAgentCallbacks, close, findAgent, findSubAgent, fromConfig, parentAgent, parentAgent, rootAgent, runAsync, runLive, runNode, subAgentsModifier and TypeMethodDescriptioncom.google.common.collect.ImmutableList<? extends Callbacks.AfterAgentCallback> com.google.common.collect.ImmutableList<? extends Callbacks.BeforeAgentCallback> com.google.common.collect.ImmutableList<? extends Callbacks.AfterAgentCallback> `afterAgentCallback` 字段的返回值是一个列表。com.google.common.collect.ImmutableList<? extends Callbacks.BeforeAgentCallback> `beforeAgentCallback` 字段解析后的结果以列表形式返回。io.reactivex.rxjava3.core.Completableclose()关闭所有子代理(sub-agents)。根据名称查找某个代理(该代理本身或其子代理)。findSubAgent(String name) 通过名称递归地搜索子代理(sub-agent)。static BaseAgentfromConfig(BaseAgentConfig config, String configAbsPath) 根据一个配置对象创建一个新的代理实例。从代理树中检索父代理。protected voidparentAgent(BaseAgent parentAgent) 用于设置父代理(即负责管理其他代理的代理)。通过向上遍历父代理链,返回该代理的根代理。io.reactivex.rxjava3.core.Flowable<Event> runAsync(InvocationContext parentContext) 异步运行代理程序。io.reactivex.rxjava3.core.Flowable<Event> runLive(InvocationContext parentContext) 同步运行代理程序。io.reactivex.rxjava3.core.Flowable<Event> 将该代理作为工作流中的一个节点来运行,并将其部署在该节点的分支上;这样,后续的节点就能够接收到该代理产生的事件(即数据或信号)。Methods inherited from class BaseNode
config, description, inputSchema, name, outputSchema, rerunOnResume, stateSchema, validateOutgoingEdges, waitForOutputModifier and TypeMethodDescriptionconfig()返回该节点的重试策略(retry policy)和执行超时时间(execution timeout)。该函数会返回节点的具体功能或行为,这些信息既适用于人类用户,也适用于可能调用该节点的模型(即那些需要使用该节点功能的系统或应用程序)。Optional<com.google.genai.types.Schema> 返回该节点的输入数据必须匹配的规范(即数据结构或格式)。final Stringname()返回用于标识该节点在其图中的名称。Optional<com.google.genai.types.Schema> 返回一个规范(schema),该规范要求节点的输出值必须符合这个规范的要求。boolean返回值true如果一个被恢复的节点重新从头开始运行,那么它并不会输出“恢复成功”的结果,而是会继续执行之前的操作。Optional<com.google.genai.types.Schema> 返回用于描述该节点所使用的状态键(state keys)的架构(schema)。protected voidvalidateOutgoingEdges(Collection<Edge> edges) 抛出异常(或错误)GraphValidationException如果这个节点无法提供服务(即无法完成其预定的功能或任务),那么就需要寻找其他节点来替代它。edges这些因素会“留下”某些东西(例如:用于生成某种路径的边缘信息),但这些路径实际上永远不会被真正生成(即:这些边缘信息永远不会被用于实际的路由计算中)。boolean返回值true如果某个节点在产生输出或确定路由之前仍然可以被重新触发(即可以继续被执行),那么它就不会在自身执行完成后立即停止运行。Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Node
requiresAllPredecessorsModifier and TypeMethodDescriptiondefault boolean返回值true如果该节点仅在所有前置节点都完成执行后才会被运行,并且会接收所有以节点名称为键的前置节点的输出结果(就像一个“扇入型”节点一样)。
-
方法详细信息(Method Details)
-
builder
-
isStreaming
public boolean isStreaming() -
runAsyncImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext) 描述内容复制自相关类:BaseAgent与特定代理(Agent)相关的异步逻辑(Agent-specific asynchronous logic)。- Specified by:
runAsyncImplin classBaseAgent- Parameters:
invocationContext- Current invocation context.- Returns:
- stream of agent-generated events.
-
runLiveImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext) 描述内容复制自相关类:BaseAgent与特定代理相关的同步逻辑(Agent-specific synchronous logic)。- Specified by:
runLiveImplin classBaseAgent- Parameters:
invocationContext- Current invocation context.- Returns:
- stream of agent-generated events.
-
toolOrigin
描述内容复制自相关类:BaseAgent当该代理被用作工具时,该方法会返回该工具的来源信息。- Overrides:
toolOriginin classBaseAgent- Returns:
- the tool origin, defaults to "BASE_AGENT".
-