番外篇一:《Spring AI Alibaba 到底是啥?一张图理清两者关系》

这是专栏的番外篇。前面 16 篇我们把 Spring AI 从写诗一路写到了 RAG 知识库;从本篇起,开启一段番外------聊聊站在 Spring AI 肩膀上的 Spring AI Alibaba。先别急着学新 API,咱们把"Spring AI"和"Spring AI Alibaba"这对容易搞混的概念,彻底掰扯清楚。

一、懵圈现场

先说个我自己的真实状态。

前不久我也把 Spring AI 啃完了:第 1 篇让 AI 写了首诗,第 5 篇用 @Tool 让 AI 自己查天气,第 8 篇接了 GitHub 的 MCP Server,第 12~16 篇一路把 RAG 知识库从 Embedding 写到查询改写。

然后我信心满满点开 Spring AI Alibaba 的官方文档,迎面就是:

  • ReactAgent
  • Graph 工作流
  • 多智能体编排(Sequential / Parallel / Routing / Loop)
  • 人机协同(HITL)
  • A2A 跨服务通信

我当场就懵了:这堆东西跟我刚学的 Spring AI 到底啥关系?是不是又得从零学一遍?

二、一句话定调

Spring AI Alibaba 不是"另一个 Spring AI",而是站在 Spring AI 肩膀上的"智能体编排层"。

打个大家一定秒懂的后端老鸟比方:

  • Spring AI ≈ JDBC 。它定义了一套统一的标准接口:ChatClientMessageToolVectorStore......不管底下是 OpenAI 还是通义千问,写的代码长一个样。前 16 篇折腾的全是这一层。
  • Spring AI Alibaba ≈ 在 JDBC 之上长出来的"业务编排框架" 。它不重新发明模型 / 工具 / 向量库(那些还是 Spring AI 的原子能力),而是给你更高级的"拼装件":Agent(会自己思考调工具)、Graph(把多个步骤编排成有向图)、多智能体(多个 Agent 协作)

所以结论先拍这儿:前面学的 Spring AI,100% 不会白学,全部复用。 Alibaba 只是在它上面又叠了一层。

三、官方眼里的三层架构

官方文档地址:java2ai.com/docs/overvi...

翻开 java2ai.com 的概览,人家自己就把项目拆成了三层(从上到下):

复制代码
┌─────────────────────────────────────────────┐
│  Agent Framework 层                          │
│  ReactAgent / 多智能体 / 上下文工程 / 人机协同 │
├─────────────────────────────────────────────┤
│  Graph 层(运行时基座)                       │
│  有向图编排:条件路由 / 并行 / 嵌套 / 状态管理 │
├─────────────────────────────────────────────┤
│  Augmented LLM 层 = Spring AI 原子抽象        │
│  Model / Tool / MCP / Message / VectorStore   │
└─────────────────────────────────────────────┘

这时候大家也看明白了?

  • 最底下那层,就是已经掌握的 Spring AI。 模型、工具、MCP、消息、向量库,一个没多。
  • 中间 Graph 层,是 Alibaba 自己写的"图运行时"。 它才是 ReactAgent 真正跑的地方。
  • 最上面 Agent Framework 层,是把下面两层包起来的"易用壳"。 ReactAgent.builder() 几行代码,框架帮你把上下文工程、工具调度、多轮推理全管了。

四、直接上手体验

光说概念虚,我直接把正在写的 demo 工程 yunxi-spring-ai-alibaba 的依赖贴出来:

xml 复制代码
    <dependencies>
        <dependency>
            <groupId>com.alibaba.cloud.ai</groupId>
            <artifactId>spring-ai-alibaba-agent-framework</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud.ai</groupId>
            <artifactId>spring-ai-alibaba-starter-dashscope</artifactId>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.alibaba.cloud.ai</groupId>
                <artifactId>spring-ai-alibaba-bom</artifactId>
                <version>1.1.2.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-bom</artifactId>
                <version>1.1.2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud.ai</groupId>
                <artifactId>spring-ai-alibaba-extensions-bom</artifactId>
                <version>1.1.2.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

看见没?starter-dashscope 就是通义千问的接入包,它产出的就是标准 ChatModel------也就是Spring AI 第 1 篇里那个 ChatModel

再看我是怎么造 Agent 的:

scss 复制代码
@Bean
public ReactAgent reactAgent(ChatModel chatModel, WeatherTools weatherTools) {
    return ReactAgent.builder()
            .name("demo-react-agent")
            .model(chatModel)            // ← 直接喂认识的 ChatModel
            .instruction("你是一个智能助手......")
            .methodTools(weatherTools)   // ← 第5篇的 @Tool 直接挂上
            .enableLogging(true)
            .build();
}

ChatModel 是旧的, @Tool 是旧的,只有 ReactAgent 是新的。 这就是"复用"二字最直白的证明。

六、番外篇怎么排

番外篇我也不知道该怎么写,只能抽时间慢慢写吧,我打算这么排:

  1. 番外一(本篇):Spring AI vs Alibaba 关系定位
  2. 番外二:ReactAgent 十分钟上手
  3. 番外三:扒开 ReactAgent 的 Graph 内核
  4. 番外四:StateGraph 并行 / 分支 / 状态编排实战
  5. 番外五:HITL------让 Agent 在关键时刻等人工拍板
  6. 番外六:四种多智能体模式(Sequential / Parallel / Routing / Loop)开箱即用
  7. 番外七:用 Nacos 玩转 Agent 间通信(A2A)
  8. 番外八:上生产前的坑------状态持久化、检查点、流式、错误处理
  9. 番外九:综合实战------把 RAG 和 Agent 焊在一起

收尾

回头看开头的懵圈------其实答案特简单:Spring AI 教你"造零件",Spring AI Alibaba 教你"用零件拼出会思考、会协作、能让人把关的智能体"。 你手里的 Spring AI 功夫,一字没废。

下一篇,咱们用十行代码真把 ReactAgent 跑起来。

相关推荐
逻辑帧1 小时前
洞见AI本质系列-参数的演化
ai编程
9i编程1 小时前
工具是编程的铠甲(下篇):从文件对比、全文搜索到数据库设计
后端·openai·ai编程
用户45989204565161 小时前
我用 AI Agent 自动生成了整个 App 的业务地图(开源)
ai编程·客户端
ServBay2 小时前
MCP Server 是什么?为什么是2026年开发团队的必备?
aigc·ai编程·mcp
Cerrda2 小时前
把团队 Mock 工作流做成可安装 Skill:faker-mock-setup 上架 skills.sh 实践
ai编程·cursor
八号当铺3 小时前
使用 Figma Agent Kit:插件 + MCP + 还原 Skill,打通本地设计协作
前端·人工智能·ai编程
无责任此方_修行中3 小时前
搓了一个国产大模型与 AI Agent 比价工具
前端·后端·ai编程
奈斯先生vector3 小时前
遗留系统不是让 AI 重写一遍:代码智能体驱动的行为保护式现代化
ai编程
MomentYY4 小时前
RAG 图检索&多跳推理:有些答案需要“顺藤摸瓜”
人工智能·agent·ai编程