PageSourceSearch

https://java2ai.com/assets/js/ffb311b0.b22f6a64.js

js java2ai.com collected 2026-10-03 21:36:48 UTC 26,182 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkspring_ai_alibaba_website=self.webpackChunkspring_ai_alibaba_website||[]).push([[6518],{8913:(e,n,a)=>{a.r(n),a.d(n,{assets:()=>d,contentTitle:()=>s,default:()=>g,frontMatter:()=>l,metadata:()=>r,toc:()=>o});const r=JSON.parse('{"id":"frameworks/agent-framework/advanced/a2a","title":"\u5206\u5e03\u5f0f\u667a\u80fd\u4f53\uff08A2A Agent\uff09","description":"\u4e86\u89e3\u5982\u4f55\u5728Spring AI Alibaba\u4e2d\u4f7f\u7528A2A\u534f\u8bae\u5b9e\u73b0\u5206\u5e03\u5f0fAgent\u901a\u4fe1\uff0c\u5305\u62ecAgent\u6ce8\u518c\u3001\u53d1\u73b0\u548c\u8fdc\u7a0b\u8c03\u7528","source":"@site/docs/frameworks/agent-framework/advanced/a2a.md","sourceDirName":"frameworks/agent-framework/advanced","slug":"/frameworks/agent-framework/advanced/a2a","permalink":"/docs/frameworks/agent-framework/advanced/a2a","draft":false,"unlisted":false,"editUrl":"https://github.com/spring-ai-alibaba/website/tree/main/docs/frameworks/agent-framework/advanced/a2a.md","tags":[],"version":"current","lastUpdatedBy":"ken.lj","lastUpdatedAt":1763347264000,"frontMatter":{"title":"\u5206\u5e03\u5f0f\u667a\u80fd\u4f53\uff08A2A Agent\uff09","description":"\u4e86\u89e3\u5982\u4f55\u5728Spring AI Alibaba\u4e2d\u4f7f\u7528A2A\u534f\u8bae\u5b9e\u73b0\u5206\u5e03\u5f0fAgent\u901a\u4fe1\uff0c\u5305\u62ecAgent\u6ce8\u518c\u3001\u53d1\u73b0\u548c\u8fdc\u7a0b\u8c03\u7528","keywords":["A2A","Agent-to-Agent","\u5206\u5e03\u5f0fAgent","\u8fdc\u7a0bAgent","Nacos","Agent\u6ce8\u518c","Agent\u53d1\u73b0"]},"sidebar":"docsSidebar","previous":{"title":"\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08RAG\uff09","permalink":"/docs/frameworks/agent-framework/advanced/rag"},"next":{"title":"Graph \u5de5\u4f5c\u6d41\u7f16\u6392\u6307\u5357","permalink":"/docs/frameworks/graph-core/quick-start"}}');var i=a(74848),t=a(28453);const l={title:"\u5206\u5e03\u5f0f\u667a\u80fd\u4f53\uff08A2A Agent\uff09",description:"\u4e86\u89e3\u5982\u4f55\u5728Spring AI Alibaba\u4e2d\u4f7f\u7528A2A\u534f\u8bae\u5b9e\u73b0\u5206\u5e03\u5f0fAgent\u901a\u4fe1\uff0c\u5305\u62ecAgent\u6ce8\u518c\u3001\u53d1\u73b0\u548c\u8fdc\u7a0b\u8c03\u7528",keywords:["A2A","Agent-to-Agent","\u5206\u5e03\u5f0fAgent","\u8fdc\u7a0bAgent","Nacos","Agent\u6ce8\u518c","Agent\u53d1\u73b0"]},s=void 0,d={},o=[{value:"A2A \u534f\u8bae\u7b80\u4ecb",id:"a2a-\u534f\u8bae\u7b80\u4ecb",level:2},{value:"A2A \u67b6\u6784",id:"a2a-\u67b6\u6784",level:2},{value:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u6d41\u7a0b",id:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u6d41\u7a0b",level:3},{value:"\u53d1\u5e03 A2A \u667a\u80fd\u4f53",id:"\u53d1\u5e03-a2a-\u667a\u80fd\u4f53",level:2},{value:"\u5b9a\u4e49\u672c\u5730 Agent",id:"\u5b9a\u4e49\u672c\u5730-agent",level:3},{value:"\u914d\u7f6e A2A Server",id:"\u914d\u7f6e-a2a-server",level:3},{value:"\u8c03\u7528 A2A \u8fdc\u7a0b\u667a\u80fd\u4f53",id:"\u8c03\u7528-a2a-\u8fdc\u7a0b\u667a\u80fd\u4f53",level:2},{value:"\u4f7f\u7528 AgentCardProvider \u53d1\u73b0 Agent",id:"\u4f7f\u7528-agentcardprovider-\u53d1\u73b0-agent",level:3},{value:"\u57fa\u4e8e Nacos \u7684 A2A Registry",id:"\u57fa\u4e8e-nacos-\u7684-a2a-registry",level:2},{value:"\u914d\u7f6e Nacos Registry \u548c Discovery",id:"\u914d\u7f6e-nacos-registry-\u548c-discovery",level:3},{value:"\u5b8c\u6574\u793a\u4f8b",id:"\u5b8c\u6574\u793a\u4f8b",level:3},{value:"\u9a8c\u8bc1\u548c\u6d4b\u8bd5",id:"\u9a8c\u8bc1\u548c\u6d4b\u8bd5",level:2},{value:"\u9a8c\u8bc1\u672c\u5730 AgentCard",id:"\u9a8c\u8bc1\u672c\u5730-agentcard",level:3},{value:"\u9a8c\u8bc1 Nacos \u6ce8\u518c",id:"\u9a8c\u8bc1-nacos-\u6ce8\u518c",level:3},{value:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u7684\u533a\u522b",id:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u7684\u533a\u522b",level:3},{value:"\u6ce8\u610f\u4e8b\u9879",id:"\u6ce8\u610f\u4e8b\u9879",level:2},{value:"\u6545\u969c\u6392\u67e5",id:"\u6545\u969c\u6392\u67e5",level:2},{value:"Agent \u6ca1\u6709\u6ce8\u518c\u5230 Nacos",id:"agent-\u6ca1\u6709\u6ce8\u518c\u5230-nacos",level:3},{value:"AgentCardProvider \u65e0\u6cd5\u53d1\u73b0 Agent",id:"agentcardprovider-\u65e0\u6cd5\u53d1\u73b0-agent",level:3},{value:"\u8fdc\u7a0b\u8c03\u7528\u5931\u8d25",id:"\u8fdc\u7a0b\u8c03\u7528\u5931\u8d25",level:3}];function c(e){const n={a:"a",code:"code",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,t.R)(),...e.components},{Code:a}=n;return a||function(e,n){throw new Error("Expected "+(n?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Code",!0),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h2,{id:"a2a-\u534f\u8bae\u7b80\u4ecb",children:"A2A \u534f\u8bae\u7b80\u4ecb"}),"\n",(0,i.jsxs)(n.p,{children:["\u968f\u7740\u667a\u80fd\u4f53\u5e94\u7528\u7684\u5e7f\u6cdb\u843d\u5730\uff0c\u667a\u80fd\u4f53\u5e94\u7528\u95f4\u7684\u5206\u5e03\u5f0f\u90e8\u7f72\u4e0e\u8fdc\u7a0b\u9
101a\u4fe1\u6210\u4e3a\u8981\u89e3\u51b3\u7684\u5173\u952e\u95ee\u9898\uff0cGoogle \u63a8\u51fa\u7684 ",(0,i.jsx)(n.a,{href:"https://a2a-protocol.org/latest/",children:"Agent2Agent\uff08A2A\uff09\u534f\u8bae"}),"\u5373\u9762\u5411\u8fd9\u4e00\u843d\u5730\u573a\u666f\uff1aA2A \u89e3\u51b3\u667a\u80fd\u4f53\u4e0e\u5176\u4ed6\u4f7f\u7528\u4e0d\u540c\u6846\u67b6\u3001\u90e8\u7f72\u5728\u4e0d\u540c\u673a\u5668\u3001\u4e0d\u540c\u516c\u53f8\u7684\u667a\u80fd\u4f53\u8fdb\u884c\u6709\u6548\u901a\u4fe1\u548c\u534f\u4f5c\u7684\u95ee\u9898\u3002"]}),"\n",(0,i.jsx)(n.p,{children:"A2A \u534f\u8bae\u5b9a\u4e49\u4e86\u667a\u80fd\u4f53\u4e4b\u95f4\u901a\u4fe1\u7684\u6807\u51c6\u65b9\u5f0f\uff0c\u4f7f\u5f97\u4e0d\u540c\u6846\u67b6\u3001\u4e0d\u540c\u90e8\u7f72\u73af\u5883\u7684\u667a\u80fd\u4f53\u80fd\u591f\u65e0\u7f1d\u534f\u4f5c\u3002"}),"\n",(0,i.jsx)(n.h2,{id:"a2a-\u67b6\u6784",children:"A2A \u67b6\u6784"}),"\n",(0,i.jsx)(n.p,{children:"Spring AI Alibaba \u7684 A2A \u5b9e\u73b0\u5305\u542b\u4e09\u4e2a\u6838\u5fc3\u7ec4\u4ef6\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"A2A Server"}),"\uff1a\u5c06\u672c\u5730 ReactAgent \u66b4\u9732\u4e3a A2A \u670d\u52a1"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"A2A Registry"}),"\uff1aAgent \u6ce8\u518c\u4e2d\u5fc3\uff08\u652f\u6301 Nacos\uff09"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:"A2A Discovery"}),"\uff1aAgent \u53d1\u73b0\u673a\u5236\uff08\u652f\u6301 Nacos\uff09"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u6d41\u7a0b",children:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u6d41\u7a0b"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510         \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510         \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502  Agent Provider \u2502         \u2502  Nacos       \u2502         \u2502  Agent Consumer \u2502\n\u2502  (\u672c\u5730Agent)    \u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b6\u2502  Registry    \u2502\u25c0\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502  (\u8fdc\u7a0b\u8c03\u7528)     \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518         \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518         \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n       \u2502                            \u2502                          \u2502\n       \u2502 1. \u6ce8\u518c AgentCard          \u2502                          \u2502\n       \u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b6\u2502                          \u2502\n       \u2502                            \u2502                          \u2502\n       \u2502                            \u2502 2. \u67e5\u8be2 AgentCard        \u2502\n       \u2502                            \u2502\u25c0\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502\n       \u2502                            \u2502                          \u2502\n       \u2502 3. \u8fdc\u7a0b\u8c03\u7528                \u2502                          \u2502\n       \u2502\u25c0\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502                          \u2502\n       \u2502                            \u2502                          \u2502\n"})}),"\n",(0,i.jsx)(n.h2,{id:"\u53d1\u5e03-a2a-\u667a\u80fd\u4f53",children:"\u53d1\u5e03 A2A \u667a\u80fd\u4f53"}),"\n",(0,i.jsx)(n.p,{children:"\u8981\u5c06\u4e00\u4e2a\u667a\u80fd\u4f53\u53d1\u5e03\u4e3a A2A \u670d\u52a1\uff0c\u9700\u8981\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"\u521b\u5efa ReactAgent Bean"}),"\n",(0,i.jsx)(n.li,{children:"\u914d\u7f6e A2A Server"}),"\n",(0,i.jsx)(n.li,{children:"\uff08\u53ef\u9009\uff09\u914d\u7f6e Nacos Registry \u8fdb\u884c\u81ea\u52a8\u6ce8\u518c"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u5b9a\u4e49\u672c\u5730-agent",children:"\u5b9a\u4e49\u672c\u5730 Agent"}),"\n",(0,i.jsx)(a,{language:"java",title:"\u5b9a\u4e49\u672c\u5730 ReactAgent \u793a\u4f8b",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/framework/advanced/A2AExample.java",children:'import 
1com.alibaba.cloud.ai.graph.agent.ReactAgent;\nimport org.springframework.ai.chat.model.ChatModel;\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\n\n@Configuration\npublic class A2AAgentConfig {\n\n  @Bean(name = "dataAnalysisAgent")\n  public ReactAgent dataAnalysisAgent(@Qualifier("dashscopeChatModel") ChatModel chatModel) {\n      return ReactAgent.builder()\n              .name("data_analysis_agent")\n              .model(chatModel)\n              .description("\u4e13\u95e8\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u7edf\u8ba1\u8ba1\u7b97\u7684\u672c\u5730\u667a\u80fd\u4f53")\n              .instruction("\u4f60\u662f\u4e00\u4e2a\u4e13\u4e1a\u7684\u6570\u636e\u5206\u6790\u4e13\u5bb6\uff0c\u64c5\u957f\u5904\u7406\u5404\u7c7b\u6570\u636e\u7edf\u8ba1\u548c\u5206\u6790\u4efb\u52a1\u3002" +\n                      "\u4f60\u80fd\u591f\u7406\u89e3\u7528\u6237\u7684\u6570\u636e\u5206\u6790\u9700\u6c42\uff0c\u63d0\u4f9b\u51c6\u786e\u7684\u7edf\u8ba1\u8ba1\u7b97\u7ed3\u679c\u548c\u4e13\u4e1a\u7684\u5206\u6790\u5efa\u8bae\u3002")\n              .outputKey("messages")\n              .build();\n  }\n}'}),"\n",(0,i.jsx)(n.h3,{id:"\u914d\u7f6e-a2a-server",children:"\u914d\u7f6e A2A Server"}),"\n",(0,i.jsxs)(n.p,{children:["\u5728 ",(0,i.jsx)(n.code,{children:"application.yml"})," \u4e2d\u914d\u7f6e A2A Server\uff1a"]}),"\n",(0,i.jsx)(a,{language:"yaml",title:"A2A Server \u914d\u7f6e\u793a\u4f8b",children:"spring:\nai:\n  alibaba:\n    a2a:\n      server:\n        version: 1.0.0\n        card:\n          name: data_analysis_agent\n          description: \u4e13\u95e8\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u7edf\u8ba1\u8ba1\u7b97\u7684\u672c\u5730\u667a\u80fd\u4f53\n          provider:\n            name: Spring AI Alibaba Documentation\n            organization: Spring AI Alibaba"}),"\n",(0,i.jsx)(n.p,{children:"\u542f\u52a8\u5e94\u7528\u540e\uff0cA2A Server \u4f1a\u81ea\u52a8\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u6839\u636e ReactAgent Bean \u751f\u6210 AgentCard"}),"\n",(0,i.jsxs)(n.li,{children:["\u66b4\u9732 REST API \u7aef\u70b9\uff1a","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"/.well-known/agent.json"})," - AgentCard \u5143\u6570\u636e"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"/a2a/message"})," - Agent \u8c03\u7528\u7aef\u70b9"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u8c03\u7528-a2a-\u8fdc\u7a0b\u667a\u80fd\u4f53",children:"\u8c03\u7528 A2A \u8fdc\u7a0b\u667a\u80fd\u4f53"}),"\n",(0,i.jsx)(n.h3,{id:"\u4f7f\u7528-agentcardprovider-\u53d1\u73b0-agent",children:"\u4f7f\u7528 AgentCardProvider \u53d1\u73b0 Agent"}),"\n",(0,i.jsxs)(n.p,{children:["Spring AI Alibaba \u652f\u6301\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"AgentCardProvider"})," \u4ece\u6ce8\u518c\u4e2d\u5fc3\uff08\u5982 Nacos\uff09\u53d1\u73b0\u8fdc\u7a0b Agent\u3002"]}),"\n",(0,i.jsx)(a,{language:"java",title:"\u4f7f\u7528 AgentCardProvider \u53d1\u73b0\u5e76\u8c03\u7528\u8fdc\u7a0b Agent",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/framework/advanced/A2AExample.java",children:'import com.alibaba.cloud.ai.graph.agent.a2a.A2aRemoteAgent;\nimport com.alibaba.cloud.ai.graph.agent.a2a.AgentCardProvider;\nimport com.alibaba.cloud.ai.graph.OverAllState;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Component;\n\nimport java.util.Optional;\n\n@Component\npublic class A2AExample {\n\n  private final AgentCardProvider agentCardProvider;\n\n  @Autowired\n  public A2AExample(AgentCardProvider agentCardProvider) {\n      this.agentCardProvider = agentCardProvider;\n  }\n\n  public void callRemoteAgent() {\n      // \u901a\u8fc7 AgentCardProvider \u4ece\u6ce8\u518c\u4e2d\u5fc3\u53d1\u73b0 Agent\n      A2aRemoteAgent remote = A2aRemoteAgent.builder()\n              .name("data_analysis_agent")\n              .agentCardProvider(agentCardProvider)  // \u4ece Nacos \u81ea\u52a8\u83b7\u53d6 AgentCard\n              .description("\u6570\u636e\u5206\u6790\u8fdc\u7a0b\u4ee3\u74
106")\n              .build();\n\n      // \u8fdc\u7a0b\u8c03\u7528\n      Optional<OverAllState> result = remote.invoke("\u8bf7\u6839\u636e\u5b63\u5ea6\u6570\u636e\u7ed9\u51fa\u540c\u6bd4\u4e0e\u73af\u6bd4\u5206\u6790\u6982\u8981\u3002");\n      \n      result.ifPresent(state -> {\n          System.out.println("\u8c03\u7528\u6210\u529f: " + state.value("output"));\n      });\n  }\n}'}),"\n",(0,i.jsx)(n.h2,{id:"\u57fa\u4e8e-nacos-\u7684-a2a-registry",children:"\u57fa\u4e8e Nacos \u7684 A2A Registry"}),"\n",(0,i.jsx)(n.p,{children:"Nacos3 \u6700\u65b0\u7248\u672c\u63d0\u4f9b\u4e86 A2A AgentCard \u6a21\u578b\u7684\u5b58\u50a8\u4e0e\u63a8\u9001\u652f\u6301\uff0c\u56e0\u6b64\u53ef\u4ee5\u4f5c\u4e3a A2A Registry \u5b9e\u73b0\u3002Spring AI Alibaba \u901a\u8fc7\u4e0e Nacos A2A Registry \u96c6\u6210\uff0c\u53ef\u4ee5\u5b9e\u73b0\uff1a"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"A2A Server AgentCard \u81ea\u52a8\u6ce8\u518c\u5230 Nacos A2A Registry"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.strong,{children:"A2a Client \u81ea\u52a8\u8ba2\u9605\u53d1\u73b0\u53ef\u7528 AgentCard\uff0c\u5b9e\u73b0 AgentCard \u8c03\u7528\u7684\u8d1f\u8f7d\u5747\u8861"})}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u914d\u7f6e-nacos-registry-\u548c-discovery",children:"\u914d\u7f6e Nacos Registry \u548c Discovery"}),"\n",(0,i.jsx)(a,{language:"yaml",title:"Nacos A2A \u914d\u7f6e\u793a\u4f8b",children:"spring:\nai:\n  alibaba:\n    a2a:\n      nacos:\n        server-addr: 127.0.0.1:8848\n        username: nacos\n        password: nacos\n        discovery:\n          enabled: true   # \u542f\u7528\u670d\u52a1\u53d1\u73b0\uff08\u67e5\u8be2\u5176\u4ed6 Agent\uff09\n        registry:\n          enabled: true   # \u542f\u7528\u670d\u52a1\u6ce8\u518c\uff08\u6ce8\u518c\u672c\u5730 Agent\uff09\n      server:\n        version: 1.0.0\n        card:\n          name: data_analysis_agent\n          description: \u4e13\u95e8\u7528\u4e8e\u6570\u636e\u5206\u6790\u548c\u7edf\u8ba1\u8ba1\u7b97\u7684\u672c\u5730\u667a\u80fd\u4f53\n          provider:\n            name: Spring AI Alibaba Documentation\n            organization: Spring AI Alibaba"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u91cd\u8981\u914d\u7f6e\u8bf4\u660e"}),"\uff1a"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"registry.enabled: true"})," - \u5fc5\u987b\u542f\u7528\u624d\u80fd\u5c06 Agent \u6ce8\u518c\u5230 Nacos\uff08\u670d\u52a1\u63d0\u4f9b\u8005\uff09"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"discovery.enabled: true"})," - \u542f\u7528\u540e\u624d\u80fd\u901a\u8fc7 AgentCardProvider \u53d1\u73b0\u5176\u4ed6 Agent\uff08\u670d\u52a1\u6d88\u8d39\u8005\uff09"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"server.card.name"})," - \u5fc5\u987b\u4e0e ReactAgent Bean \u7684 ",(0,i.jsx)(n.code,{children:"name"})," \u4e00\u81f4"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u5b8c\u6574\u793a\u4f8b",children:"\u5b8c\u6574\u793a\u4f8b"}),"\n",(0,i.jsx)(a,{language:"java",title:"A2A \u4e00\u4f53\u5316\u793a\u4f8b\uff1a\u6ce8\u518c -> \u53d1\u73b0 -> \u8c03\u7528",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/framework/advanced/A2AExample.java",children:'import com.alibaba.cloud.ai.graph.agent.ReactAgent;\nimport com.alibaba.cloud.ai.graph.agent.a2a.A2aRemoteAgent;\nimport com.alibaba.cloud.ai.graph.agent.a2a.AgentCardProvider;\nimport com.alibaba.cloud.ai.graph.OverAllState;\nimport org.springframework.ai.chat.model.ChatModel;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.beans.factory.annotation.Qualifier;\nimport org.springframework.stereotype.Component;\n\nimport java.util.Optional;\n\n@Component\npublic class A2AExample {\n\n  private final ChatModel chatModel;\n  private final AgentCardProvider agentCardProvider;\n  private final ReactAgent localDataAnalysisAgent;\n\n  @Autowired\n  public A2AExample(@Qualifier("dashscopeChatModel") ChatModel chatModel,\n                    AgentCardProvider agentCardProvider,\n                    @Qualifier("dataAnalysisAgent") ReactAgent localDataAnalysisAgent) {\n      this.chatModel = chatModel;\n      this.agentCardProvider = agentCardProvider;\n      this.localDataAnalysisAgent = localDataAnalysisAgent;\n  }
1\n\n  public void runDemo() {\n      // 1. \u672c\u5730\u76f4\u8fde\uff1a\u9a8c\u8bc1\u672c\u5730\u6ce8\u518c\u7684 ReactAgent \u53ef\u7528\n      Optional<OverAllState> localResult = localDataAnalysisAgent.invoke(\n          "\u8bf7\u5bf9\u4e0a\u6708\u9500\u552e\u6570\u636e\u8fdb\u884c\u8d8b\u52bf\u5206\u6790\uff0c\u5e76\u7ed9\u51fa\u5173\u952e\u7ed3\u8bba\u3002"\n      );\n      localResult.ifPresent(state -> {\n          System.out.println("\u672c\u5730\u8c03\u7528\u6210\u529f");\n      });\n\n      // 2. \u53d1\u73b0\uff1a\u901a\u8fc7 AgentCardProvider \u4ece\u6ce8\u518c\u4e2d\u5fc3\u83b7\u53d6\u8be5 Agent \u7684 AgentCard\n      A2aRemoteAgent remote = A2aRemoteAgent.builder()\n              .name("data_analysis_agent")\n              .agentCardProvider(agentCardProvider)  // \u4ece Nacos \u81ea\u52a8\u83b7\u53d6 AgentCard\n              .description("\u6570\u636e\u5206\u6790\u8fdc\u7a0b\u4ee3\u7406")\n              .build();\n\n      // 3. \u8fdc\u7a0b\u8c03\u7528\uff1a\u901a\u8fc7 A2aRemoteAgent \u8c03\u7528\n      Optional<OverAllState> remoteResult = remote.invoke(\n          "\u8bf7\u6839\u636e\u5b63\u5ea6\u6570\u636e\u7ed9\u51fa\u540c\u6bd4\u4e0e\u73af\u6bd4\u5206\u6790\u6982\u8981\u3002"\n      );\n      remoteResult.ifPresent(state -> {\n          System.out.println("\u8fdc\u7a0b\u8c03\u7528\u6210\u529f");\n      });\n  }\n}'}),"\n",(0,i.jsx)(n.h2,{id:"\u9a8c\u8bc1\u548c\u6d4b\u8bd5",children:"\u9a8c\u8bc1\u548c\u6d4b\u8bd5"}),"\n",(0,i.jsx)(n.h3,{id:"\u9a8c\u8bc1\u672c\u5730-agentcard",children:"\u9a8c\u8bc1\u672c\u5730 AgentCard"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:"curl http://localhost:8080/.well-known/agent.json\n"})}),"\n",(0,i.jsx)(n.h3,{id:"\u9a8c\u8bc1-nacos-\u6ce8\u518c",children:"\u9a8c\u8bc1 Nacos \u6ce8\u518c"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\u6253\u5f00 Nacos \u63a7\u5236\u53f0\uff1a",(0,i.jsx)(n.a,{href:"http://localhost:8848/nacos",children:"http://localhost:8848/nacos"})]}),"\n",(0,i.jsx)(n.li,{children:"\u767b\u5f55\uff08nacos/nacos\uff09"}),"\n",(0,i.jsx)(n.li,{children:"\u67e5\u770b A2A \u670d\u52a1\u6ce8\u518c\u7ef4\u5ea6\uff0c\u5e94\u8be5\u80fd\u770b\u5230\u6ce8\u518c\u7684 Agent"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u7684\u533a\u522b",children:"\u6ce8\u518c\u4e0e\u53d1\u73b0\u7684\u533a\u522b"}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"\u529f\u80fd"}),(0,i.jsx)(n.th,{children:"\u914d\u7f6e\u9879"}),(0,i.jsx)(n.th,{children:"\u4f5c\u7528"}),(0,i.jsx)(n.th,{children:"\u89d2\u8272"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.strong,{children:"Registry\uff08\u6ce8\u518c\uff09"})}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"registry.enabled: true"})}),(0,i.jsx)(n.td,{children:"\u5c06\u672c\u5730 Agent \u6ce8\u518c\u5230 Nacos"}),(0,i.jsx)(n.td,{children:"\u670d\u52a1\u63d0\u4f9b\u8005"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.strong,{children:"Discovery\uff08\u53d1\u73b0\uff09"})}),(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"discovery.enabled: true"})}),(0,i.jsx)(n.td,{children:"\u4ece Nacos \u67e5\u8be2\u5176\u4ed6 Agent"}),(0,i.jsx)(n.td,{children:"\u670d\u52a1\u6d88\u8d39\u8005"})]})]})]}),"\n",(0,i.jsx)(n.p,{children:"\u4e24\u8005\u53ef\u72ec\u7acb\u914d\u7f6e\uff0c\u4e5f\u53ef\u540c\u65f6\u542f\u7528\u3002\u5f53\u540c\u65f6\u542f\u7528\u65f6\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u4f5c\u4e3a",(0,i.jsx)(n.strong,{children:"\u63d0\u4f9b\u8005"}),"\uff1a\u6ce8\u518c\u672c\u5730 Agent \u5230 Nacos"]}),"\n",(0,i.jsxs)(n.li,{children:["\u4f5c\u4e3a",(0,i.jsx)(n.strong,{children:"\u6d88\u8d39\u8005"}),"\uff1a\u53ef\u53d1\u73b0\u5e76\u8c03\u7528\u5176\u4ed6\u5df2\u6ce8\u518c\u7684 Agent\uff08\u5305\u62ec\u81ea\u5df1\uff09"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u6ce8\u610f\u4e8b\u9879",children:"\u6ce8\u610f\u4e8b\u9879"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u4f9d\u8d56\u8981\u6c42"}),"\uff1a"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u9700\u8981\u6dfb\u52a0 ",(0,i.jsx)(n.code,{children:"spring-ai-alibaba-starter-
1a2a-nacos"})," \u4f9d\u8d56"]}),"\n",(0,i.jsx)(n.li,{children:"\u786e\u4fdd Nacos \u670d\u52a1\u6b63\u5e38\u8fd0\u884c"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"AgentCard \u5143\u6570\u636e"}),"\uff1a"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"server.card.name"})," \u5fc5\u987b\u4e0e ReactAgent Bean \u7684 ",(0,i.jsx)(n.code,{children:"name"})," \u4e00\u81f4"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"server.card.provider"})," \u53ef\u9009\uff0c\u7528\u4e8e\u6807\u8bc6 Agent \u63d0\u4f9b\u8005\u4fe1\u606f"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"\u591a Agent \u6ce8\u518c"}),"\uff1a"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u53ea\u6709\u4e00\u4e2a Agent Bean \u4f1a\u88ab\u6ce8\u518c"}),"\n",(0,i.jsx)(n.li,{children:"\u5982\u9700\u6ce8\u518c\u591a\u4e2a Agent\uff0c\u9700\u8fd0\u884c\u591a\u4e2a\u5e94\u7528\u5b9e\u4f8b\uff0c\u6bcf\u4e2a\u5b9e\u4f8b\u914d\u7f6e\u4e0d\u540c\u7684 Agent"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"\u6545\u969c\u6392\u67e5",children:"\u6545\u969c\u6392\u67e5"}),"\n",(0,i.jsx)(n.h3,{id:"agent-\u6ca1\u6709\u6ce8\u518c\u5230-nacos",children:"Agent \u6ca1\u6709\u6ce8\u518c\u5230 Nacos"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u68c0\u67e5 ",(0,i.jsx)(n.code,{children:"registry.enabled: true"})," \u662f\u5426\u914d\u7f6e"]}),"\n",(0,i.jsx)(n.li,{children:"\u67e5\u770b\u5e94\u7528\u65e5\u5fd7\uff0c\u786e\u8ba4 Nacos Registry AutoConfiguration \u662f\u5426\u751f\u6548"}),"\n",(0,i.jsx)(n.li,{children:"\u9a8c\u8bc1 Nacos \u8fde\u63a5\u914d\u7f6e\uff08server-addr\u3001username\u3001password\uff09"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"agentcardprovider-\u65e0\u6cd5\u53d1\u73b0-agent",children:"AgentCardProvider \u65e0\u6cd5\u53d1\u73b0 Agent"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u68c0\u67e5 ",(0,i.jsx)(n.code,{children:"discovery.enabled: true"})," \u662f\u5426\u914d\u7f6e"]}),"\n",(0,i.jsx)(n.li,{children:"\u786e\u8ba4 Agent \u5df2\u6210\u529f\u6ce8\u518c\u5230 Nacos"}),"\n",(0,i.jsx)(n.li,{children:"\u9a8c\u8bc1 agent name \u662f\u5426\u5339\u914d"}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"\u8fdc\u7a0b\u8c03\u7528\u5931\u8d25",children:"\u8fdc\u7a0b\u8c03\u7528\u5931\u8d25"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u786e\u8ba4\u76ee\u6807 Agent \u7684 REST API \u7aef\u70b9\u53ef\u8bbf\u95ee"}),"\n",(0,i.jsx)(n.li,{children:"\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u548c\u9632\u706b\u5899\u914d\u7f6e"}),"\n",(0,i.jsx)(n.li,{children:"\u67e5\u770b A2A \u6d88\u606f\u4f20\u8f93\u65e5\u5fd7"}),"\n"]})]})}function g(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},28453:(e,n,a)=>{a.d(n,{R:()=>l,x:()=>s});var r=a(96540);const i={},t=r.createContext(i);function l(e){const n=r.useContext(t);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),r.createElement(t.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.