AI 博客

Spring AI vs LangChain4j vs Eino vs Rig

四个框架都能做出会调用工具、带 RAG、接 MCP 的智能体,所以功能不是那个决定。真正把它们区分开的,是每一个对你已经在跑的运行时提出了什么要求——而对这两个 JVM 框架来说,那个要求是一个 Spring Boot 大版本。

作者 智能体 AI 维基 29 分钟读完

Spring AI 2.0 于 2026 年 6 月 12 日发布 GA,并要求 Spring Boot 4——这意味着,对一支还在 Boot 3.x 上的团队来说,给一个服务加上智能体,是一次全平台的框架迁移。这才是真正要比的东西。2026 年,这四个框架都能像样地做工具调用、检索、流式与 MCP;把它们区分开的,是每一个对你已经在跑的运行时提出了什么要求,而其中只有一个开口要一个大版本。

先看全貌

这里有两个是 JVM 框架,多数企业把它们当成可以互换的东西,而它们并不是。另外两个之所以存在,是因为一个 Go 或 Rust 服务本来就是以单个二进制的形态部署的,而没人愿意为了给它一个工具循环,去支起一个 Python 边车。

框架运行时成熟度它对你的技术栈提什么要求
Spring AI JVM,Spring Boot 1.0 GA 2025 年 5 月;2.0 GA 2026 年 6 月 12 日 Spring Boot 4.0 或 4.1、Spring Framework 7、Jackson 3
LangChain4j JVM,不绑定 Web 框架 1.0 GA 2025 年 5 月,此后稳定迭代 Java 17 与一个构建文件;Boot 3.5+ 和 Boot 4 两套 starter
Eino Go 字节跳动在 CloudWeGo 下开源;ADK 于 2026 年 4 月发布,alpha 一个 Go module,以及对一个仍标着 alpha 的智能体套件的容忍度
Rig Rust 2026 年年中越过 7,600 个 GitHub star,其中约 1,900 个是半年内新增的 一个 crate;还能编译到 WebAssembly
Where each framework commits A four by four matrix. Rows are Spring AI, LangChain4j, Eino and Rig. Columns are runtime freedom, official MCP SDK conformance tier for the framework's language, in-process orchestration, and how close the surrounding evaluation and optimisation ecosystem is. Spring AI is weak on runtime freedom because it requires Spring Boot 4, sits on the Tier 2 Java SDK which is maintained in collaboration with Spring AI itself, is strong on in-process orchestration through the Spring programming model, and medium on ecosystem proximity. LangChain4j is strong on runtime freedom because it ships starters for Spring Boot 3.5 and above as well as Boot 4 and runs under Quarkus, Micronaut or plain Java, sits on the same Tier 2 Java SDK, is medium on in-process orchestration, and medium on ecosystem proximity. Eino is strong on runtime freedom as an ordinary Go library, sits on the Tier 1 Go SDK maintained in collaboration with Google, is strong on in-process orchestration through its graph and workflow model, and weak on ecosystem proximity. Rig is strong on runtime freedom as an ordinary Rust crate that also compiles to WebAssembly, sits on the Rust SDK that was promoted to Tier 1 in August 2026, is medium on in-process orchestration, and weak on ecosystem proximity. Where each one commits RUNTIME FREEDOM MCP SDK TIER IN-PROCESS ORCHESTRATION ECOSYSTEM NEARBY Spring AI Weak · Boot 4 only Tier 2 · Java Strong · Spring model Medium LangChain4j Strong · Boot 3.5+ or 4 Tier 2 · Java Medium · compose it Medium Eino Strong · a Go library Tier 1 · Go Strong · graph + ADK Weak Rig Strong · crate, WASM Tier 1 · Rust Medium · pipelines Weak Strong Medium Weak Strong is not better. Spring AI's weak runtime freedom is the same decision as its strong integration with the platform.
每一个「强」都是一次押注,而每一次押注都由它旁边那一格来买单。

你真正要选的是什么

把这四个拿来做功能对比,几乎毫无意义——而这对它们四个都是恭维。对话抽象、工具调用、结构化输出、向量化、向量库适配、会话记忆、流式、可观测性钩子、一个 MCP 客户端,在每一个里面都是标配。如果你把同一个智能体写四遍,有意思的差别会在代码读起来怎么样,而不在它能做什么。

能在真实代码库面前活下来的那个决定,更窄也更无趣:这个依赖对它周围的运行时提出了什么要求,而我要跟着它保持更新三年,代价是多少?这个问题在这里确实有不同的答案,而对那两个 JVM 选项来说,答案跟 AI 一点关系都没有。

在 JVM 上,这是一个关于 Spring Boot 的决定

What each framework demands of the runtime you already operate A diagram in two halves. The left half shows the JVM path: an existing application on Spring Boot 3.x can adopt LangChain4j directly, because LangChain4j ships starters for both Boot 3.5 and above and Boot 4, and also runs under Quarkus, Micronaut or plain Java. Adopting Spring AI 2.0 from the same starting point first requires a platform migration to Spring Boot 4.0 or 4.1, Spring Framework 7 and Jackson 3, drawn as a gate the application must pass through. The right half shows the Go and Rust path: Eino and Rig are adopted by adding a library to a service that is already built as a single deployed binary, with no framework generation to cross, and the cost sits elsewhere — a smaller surrounding ecosystem for evaluation and optimisation tooling. THE JVM PATH Your service today Spring Boot 3.x LangChain4j Boot 3.5+ or Boot 4 starter Migrate the platform Boot 4.0 / 4.1, Framework 7 Jackson 3 Spring AI 2.0 GA 12 June 2026 Not on Boot at all? Quarkus Micronaut plain Java The agent library is a dependency. The framework generation underneath it is a programme of work, and only one of these two paths asks for it. THE GO AND RUST PATH Your service today one deployed binary Eino / Rig add a library No generation to cross No container, no framework major, no serialisation swap. Eino and Rig both target a service that already exists and both ship graph or pipeline orchestration in-process. The bill arrives somewhere else Prompt optimisers, eval harnesses and RL environment tooling still land in Python first, and stay there longest.
智能体库是一个依赖。它底下的框架代际是一项工程计划。

Spring AI 与 LangChain4j 都在 2025 年 5 月到了 1.0 GA,也都可用于生产——这正是此后写的那些对比文章最后往往落进「口味之争」的原因。Spring AI 2.0 结束了这一点。它面向 Spring Framework 7 之上的 Spring Boot 4.0 与 4.1,并把 Jackson 3 一起带了过来。如果你的资产还在 Boot 3.x 上——而大多数大型 Java 资产都还在,因为 Boot 大版本是跨季度的工程计划,还拖着一长串库的尾巴——那么 Spring AI 2.0 就不是一个你这个冲刺里能给某个服务加上的库。

LangChain4j 对同一个问题的回答刻意地不英雄主义:它为 Boot 3.5 以上发布一套 starter,为 Boot 4 另发一套,所以两个代际上都能跑;而且它根本不与某个 Web 框架绑定——Quarkus、Micronaut 与纯 Java 都是一等公民,Quarkus 那一系扩展也在积极维护(MCP 扩展于 2026 年 8 月 31 日发布了 1.13.1)。对一支想在某个服务里放进智能体、又不想动平台的团队来说,这就是全部理由,而且够了。

反过来看,就是替 Spring AI 说的那句公道话。如果你已经在 Boot 4 上,那份耦合就不再是税,而是产品本身:自动配置、Micrometer 可观测性、Spring 编程模型,以及整个应用上一条统一的升级路径。Boot 4 这个要求不是 Spring AI 路线图上的 bug,它就是那个让人们选它的紧密集成的同一个决定。因为你在 Boot 4 上而选它,而不是明明不在也要选它。

Eino 与 Rig 不是 Python 的移植——它们是部署形态

Go 与 Rust 这两个条目存在的理由,和那对 JVM 框架不一样;把它们读成「Go 版的 LangChain」,会把这里的取舍读反。它们的说法是:那个服务本来就在那儿了。它是一个二进制,毫秒级启动,没有解释器也没有 GIL,而「不用原生智能体库」的替代方案,是在它旁边跑一个 Python 进程,再在两者之间发明一套接口。

Eino 是字节跳动的,在 CloudWeGo 下开源,而这一点看得出来:它是地道的 Go,而不是一套翻译过来的 Python API;它的编排模型是显式的图与工作流,而这些图本身还能被暴露成工具;它的智能体套件覆盖了工具使用、多智能体协作、上下文管理,以及为人在回路准备的中断/恢复。它同时在字节跳动量级的产品内部承重,这比 star 数是个更好的可靠性信号。需要认真对待的保留意见是真的:ADK 那一层发布于 2026 年 4 月,明确标注为 alpha,接口可能会变。

Rig 是 Rust 生态在这件事上的重心,到 2026 年年中越过 7,600 个 GitHub star,其中约 1,900 个是上半年新增的;它带着 20 多家模型厂商、10 多个向量库集成、OpenTelemetry GenAI 语义约定、MCP 支持与 WebAssembly 兼容性。最后这一项才是别处真正难以复刻的——一个能编译成 WASM 的智能体循环,跑得到 JVM 去不了的地方——而 Rig 列出的生产用户包括 Neon、Nethermind 与 St Jude。

这两者放弃掉的是同一样东西,而且不是功能。是周边生态的密度,这正是接下来两节要讲的。

MCP 把过去用来定胜负的那条理由消解掉了

Where an agent's tool integrations live, then and now Three columns showing how the integration question changed. In the first column, the in-process era, every connector was an SDK wrapper compiled into the agent, so the count of available integrations was a property of the language and leaving Python meant leaving the catalogue behind. In the second column, drawn as the accent column, tools live behind Model Context Protocol servers reached over HTTP, so the same catalogue is available to any client that speaks the protocol and integration breadth stops being a language property. The third column names what did not move: prompt optimisers, evaluation harnesses and reinforcement-learning environment tooling are still Python libraries that import your agent rather than call it, so they do not cross the boundary the way tools did. Compiled in one SDK wrapper per service shipped inside the agent catalogue size = library count THE 2024 SHAPE leaving Python meant leaving the catalogue Behind a protocol tools run as MCP servers reached over ordinary HTTP any conforming client, any language THE 2026 SHAPE integration breadth stopped being a language property Still in-process prompt optimisers eval harnesses RL environment tooling WHAT DID NOT MOVE these import your agent rather than call it
工具在 2025 年跨过了语言边界。给你的智能体打分的那套工具没有。

两年前,用 Python 写智能体的理由不是语言本身。而是每一个集成都以编进进程的 Python SDK 包装层的形式存在,于是「你的智能体能碰到多少东西」是你所选语言的一个属性。那条理由已经悄悄失效了。工具如今活在通过普通 HTTP 触达的 MCP 服务器背后,而 2026 年 7 月的规范通过彻底移除传输层的会话管理,让这些服务器规模化运行容易了许多——无状态内核与其说是一个协议故事,不如说是一个负载均衡故事。这里的四个框架都是 MCP 客户端。那份目录是同一份目录。

在你断定 JVM 是那个保守选择之前,有一处细节值得知道。官方 MCP SDK 带有一致性等级,而在 2026-07-28 规范上,TypeScript、Python、C#、Go 与 Rust 位列一级,Java 处在二级——Rust SDK 是在 2026 年 8 月 21 日被提上去的。Java SDK 由与 Spring AI 协作维护,Go SDK 由与 Google 协作维护,所以没有哪一个是无人维护。但如果你在意的轴是协议一致性,那么那个「企业默认」的运行时,眼下落后于你本来当作冒险选项的那两个。

搬不走的,是给智能体打分的那套工具

把离开 Python 的代价说准确,因为这条警告通常含糊到没有用处。它不是集成,也不是模型支持——这里每个框架都覆盖了主流厂商。它是第二环:提示词优化器、评测台、裁判框架、轨迹分析、强化学习环境工具。这些先落地在 Python,也在 Python 里待得最久,因为它们与工具不同,并不待在一条网络边界的另一侧——它们把你的智能体 import 进来并驱动它。

务实的化解办法很无趣,而且管用:用你的语言跑智能体,用 Python 通过 HTTP 对着它跑评测。在智能体前面放一个薄薄的端点,接收一个任务、返回一条轨迹,然后把你偏好的那个评测台指过去。你失去的是进程内的钩子,换来的是一条你迟早也会想要的边界——因为一个只能在构建里跑的评测,是一个给生产打不了分的评测。

不过要为版本落差留出预算。当一项新技术到来时——更好的优化器、新的裁判协议、新的打分约定——你会在第一天就在 Python 里拿到它,而在你的框架里则要等到另一天,如果还等得到的话。如果你的竞争优势就取决于早一步吃到那一环,那这是一条支持 Python 的实打实的理由,再高的框架质量也答不上来。

什么时候该选哪个

情形选理由
已经在 Spring Boot 4 上Spring AI那份你本来要付账的耦合,现在成了特性:自动配置、Micrometer、一条统一的升级路径。
在 Boot 3.x 上,且没有排期迁移LangChain4j它对两个代际都发 starter,于是智能体不会变成一项平台工程。
Quarkus、Micronaut 或纯 JavaLangChain4j这两个里,只有它从设计上就不在乎你跑在什么之上。
一个需要工具循环的 Go 服务Eino地道的 Go、显式的图编排,底下还是一级的 MCP SDK。ADK 还是 alpha 期间请钉住版本。
Rust、边缘或 WASM 目标Rig这里没有第二个能编译到 WebAssembly,而 OTel GenAI 约定已经接好了。
你的优势在于最早吃到新的评测与优化技术还是 Python那一环并不像工具如今这样跨得过语言边界。

表格底下还有一条规则:选那个你的值班团队能在周四下午四点升级的框架。这里其余每一条标准,一个冲刺之内都还救得回来。这一条会复利好几年。

常见问题

不迁到 Spring Boot 4,能用 Spring AI 吗?

Spring AI 2.0 不行——它面向 Spring Framework 7 之上的 Boot 4.0 与 4.1,并把 Jackson 3 一起带过来。1.x 那条线仍然留给既有的 Boot 3 应用,但你这就等于选了一条会与项目注意力所在之处渐行渐远的分支。如果 Boot 4 迁移今年不在你的路线图上,那就该由这个约束来定框架,而不是反过来。

Eino 或 Rig 能上生产吗?

两者都有生产用户,只是照例要问一句「哪一层」。Eino 的内核在字节跳动的产品内部大规模使用;它的 ADK 智能体层发布于 2026 年 4 月,明确标注 alpha,所以请钉住版本、并预期那里会有接口变动。Rig 列出的生产部署包括 Neon、Nethermind 与 St Jude。「能不能上生产」这个问题,考的是你的升级纪律,不亚于考它们的。

离开 Python,会失去工具集成吗?

基本不会,而这是 2024 年以来最大的变化。集成如今活在通过 HTTP 触达的 MCP 服务器背后,而不再是进程内的 SDK 包装层,四个框架又都是 MCP 客户端,于是那份目录是共享的。你真正失去的是第二环——优化器、评测台与强化学习环境工具——它们是把你的智能体 import 进来,而不是调用它。

MCP SDK 的一致性等级在日常里真的要紧吗?

它主要在边缘处要紧:较新的规范特性、更严格的一致性检查,以及规范里的一处改动多快能传到你这里。二级不等于坏掉——Java SDK 由与 Spring AI 协作维护。但它确实意味着,如果你在对着协议最新的那些部分开发,你可能要等;而且值得知道,Go 与 Rust 眼下比 Java 高一级。

已有的 Python 智能体,该重写成 Go 或 Rust 吗?

只有当部署形态确实是你真正的问题时才该——冷启动、一个你不想要的边车、内存占用、边缘或 WASM 目标,或者一条你老是无谓地跨来跨去的服务边界。「那样会更快」很少是真实动机,也很少能在「你要丢下的那套评测工具」面前活下来。为了修一段你从没量过的延迟去做重写,是搞清楚你的延迟原本是多少的最贵的方式。

延伸阅读

本站:

项目来源: