🌐 远程 A2A 调用
# 调用其他服务中的 Agent
远端提供 A2A 协议时,使用 liteflow-agent-a2a。同一应用里的多个 Agent 直接用 EL 编排即可。
添加依赖:
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-agent-a2a</artifactId>
<version>${liteflow.version}</version>
</dependency>
创建远程组件,将 Agent Card 的地址和能力替换为实际服务声明:
import com.yomahub.liteflow.agent.a2a.A2aAgentComponent;
import com.yomahub.liteflow.agent.context.LiteFlowAgentContext;
import io.a2a.spec.AgentCapabilities;
import io.a2a.spec.AgentCard;
import io.agentscope.core.a2a.agent.card.AgentCardResolver;
import io.agentscope.core.a2a.agent.card.FixedAgentCardResolver;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("remoteOrderAgent")
public class RemoteOrderAgent extends A2aAgentComponent {
@Override
protected String remoteAgentName() {
return "remote-order-assistant";
}
@Override
protected AgentCardResolver agentCardResolver() {
AgentCard card = new AgentCard.Builder()
.name("remote-order-assistant")
.description("远程订单助手")
.url("http://127.0.0.1:9000")
.version("1.0.0")
.capabilities(new AgentCapabilities(false, false, false, List.of()))
.defaultInputModes(List.of("text"))
.defaultOutputModes(List.of("text"))
.skills(List.of())
.preferredTransport("JSONRPC")
.protocolVersion("0.3.0")
.build();
return FixedAgentCardResolver.builder().agentCard(card).build();
}
@Override
protected String userPrompt(LiteFlowAgentContext context) {
Object request = getSlot().getChainReqData(getSlot().getChainId());
return request == null ? "" : request.toString();
}
}
把 remoteOrderAgent 放进 EL 链即可。它不需要本地模型 API Key,当前只支持文本输入和输出。远端会话、工具、审批由远端负责,本地流式事件监听器不会自动接收其协议事件。
需要鉴权或自定义传输时,覆写 a2aAgentConfig() 提供 A2A 客户端配置;没有 liteflow.agent.a2a.* 属性段。
帮助我们改善此文档 (opens new window)
上次更新: 2026/09/20, 11:49:27



