Spring AI 2.1.0 GA 与 2.0.3 GA 现已发布
原题Spring AI 2.1.0 GA and 2.0.3 GA Available Now
读前速览
Spring AI 2.1.0 GA 带来了现代化的模型上下文协议、用于结构化输出的决策模型、可保留推理内容的增强型消息部分、支持智能体记忆的 Session API,以及扩展后的向量存储能力。
模型上下文协议(MCP)在 2026-07-28 修订版中被重新设计为无状态协议,取消了初始化握手,并支持客户端按请求声明能力。
这一现代协议允许服务器和客户端与旧版 MCP 连接并行工作,支持带进度报告的异步操作,还能在运行时添加或移除工具、资源和提示词,并通过订阅发送通知。
DecisionModel API 为模型提供结构化决策方式,可针对是/否、选项和评分类问题输出带概率的类型化决策。
目前有 3 种实现:使用 OpenAI Decisions API 的 OpenAiDecisionModel、无需 API 密钥即可本地运行的 OllamaDecisionModel,以及适用于 System One 协议服务器的 SystemOneDecisionModel。该 API 可用于分类、护栏和业务逻辑自动化,并支持配置置信度阈值。
现在,消息使用有序的 MessageParts(TextPart、ReasoningPart、ToolCallPart、ToolResultPart、MediaPart、UnknownPart),以保留提供方响应的顺序。
这解决了旧版单字符串格式的局限:它无法表示与工具调用交错出现的推理内容。OpaquePayload 字段可以保留 Anthropic 签名等提供方特定数据,而 UnknownPart 则会保留未建模数据块的原始 JSON,从而确保能够在所有主流聊天模型中准确重放。
Session API 取代了 ChatMemory,提供只追加的事件日志,支持长时间运行的智能体对话进行感知轮次的压缩和基于关键词的回忆。
Session 会存储包含所有消息部分的结构化事件,通过触发器和策略压缩历史记录,同时保留上下文,并支持通过搜索找回已压缩的内容。这使智能体能够拥有可扩展的记忆,而无需在 advisors 中管理状态。
现在,工具调用可以通过 requiresConfirmation 属性要求用户确认,从而支持敏感操作中的人在回路工作流。
这项功能允许机票预订或文件删除等工具暂停执行并请求批准,模型也可以等待确认后再继续,从而让智能体在生产环境中的交互更加安全。
完整摘要
Spring AI 2.1.0 GA 正式发布,主要增强包括:根据 2026-07-28 修订版更新无状态模型上下文协议(MCP);新增 DecisionModel API,可针对是/否、选项和评分决策生成结构化结果,并提供适用于 OpenAI、Ollama 和 System One 的实现;采用更丰富的消息模型,通过有序的 MessageParts 在往返传递中保留推理内容、工具调用和提供方特定的数据块;推出 Session API 取代 ChatMemory,为智能体运行框架提供能力,并支持感知轮次的压缩与回忆;支持在 11 种向量存储中使用用户自有的嵌入;修复了涉及 13 个 CVE 的安全问题。本次发布还预告了即将推出的 Spring AI Agent 项目。
目录 · 18 节
我谨代表 Spring AI 团队及所有贡献者,很高兴地宣布 Spring AI 2.1.0 已正式发布,并已在 Maven Central 上线!On behalf of the Spring AI team and everyone who has contributed, I'm happy to announce that Spring AI 2.1.0 has been released and is now available from Maven Central!
发行说明 | 升级说明 | 参考文档Release notes | Upgrade notes | Reference documentation
Spring AI 2.1 在 2.0.0 正式发布五个月后推出。它基于 Spring Boot 4.2 构建,包含来自 86 位贡献者的 430 多次提交。本文将介绍自 2.0.0 以来的所有变化:2.1 里程碑版本和发布候选版本中的功能、RC2 之后新增的内容,以及已在 2.0.1 和 2.0.2 中发布的新增功能。Spring AI 2.1 arrives five months after 2.0.0 GA. It is built on Spring Boot 4.2 and contains more than 430 commits from 86 contributors. This post covers everything that changed since 2.0.0: the features of the 2.1 milestones and release candidates, what was added after RC2, and the additions that already shipped in 2.0.1 and 2.0.2.
简而言之:The short version:
- MCP 2026-07-28。与现有版本并列的新版无状态模型上下文协议服务器和客户端。MCP 2026-07-28. Servers and clients for the new, stateless revision of the Model Context Protocol, next to the existing ones.
- 决策模型。一种全新的模型 API,用于处理带类型的“是/否”、选项和评分决策,支持三家提供商。Decision Models. A new model API for typed yes/no, choice and score decisions, with three providers.
- 更丰富的消息模型。消息包含有序部分,因此推理内容、工具调用和提供商特定的内容块都能在往返过程中保留下来。除 Chat Completions 外,还支持 OpenAI Responses API。A richer message model. Messages hold ordered parts, so reasoning, tool calls and provider-specific blocks survive a round trip. The OpenAI Responses API is supported next to Chat Completions.
- 智能体运行框架的构成模块。带有会话记忆、压缩和召回功能的 Session API 取代了 ChatMemory。工具调用可以等待人员批准,并且每轮调用次数有限;护栏拒绝会被标记为拒绝。The building blocks of an agent harness. The Session API, with session memory, compaction and recall, replaces
ChatMemory. Tool calls can wait for a person's approval and are limited per turn, and guardrail refusals are marked as such. - 使用你自己的嵌入向量。11 个向量存储库支持写入和搜索由你自行计算的向量。Your own embeddings. Eleven vector stores can write and search with vectors you computed yourself.
- 全新参考文档,按任务组织,并提供快速入门和教程。New reference documentation, organized around tasks, with a quickstart and tutorials.
- 安全性。修复了 13 个 CVE,Spring AI 2.0.3 也包含这些修复。Security. Fixes for 13 CVEs, which Spring AI 2.0.3 has as well.
- 接下来:Spring AI Agent。这是一个基于 Spring AI 2.1 构建的全新项目,用于组合和编排智能体,将于 12 月初启动孵化。请参阅“后续计划”。Next: Spring AI Agent. A new project for composing and orchestrating agents, built on Spring AI 2.1, starts incubating in early December. See What's next.
下图展示了 Spring AI 2.1 的构建模块,蓝色部分为社区项目。该图来自新版参考文档,其中各模块均链接到对应页面。The following map shows the building blocks of Spring AI 2.1, with the community projects in blue. It comes from the new reference documentation, where the blocks link to their pages.
MCP 2026-07-28MCP 2026-07-28
2026-07-28 版本是对模型上下文协议的一次重新设计。它是无状态的:没有初始化握手,也没有会话;每个请求都携带协议版本和客户端能力;而引导和采样等由服务器发起的输入则变为需要多次往返的请求。Spring AI 2.1 基于 MCP Java SDK 2.2.0,在客户端和服务器端均支持这一“现代”协议,同时也保留了现有的 STDIO、SSE、Streamable HTTP 以及无状态服务器和客户端。The 2026-07-28 revision is a redesign of the Model Context Protocol. It is stateless: there is no initialize handshake and no session, every request carries the protocol version and the client capabilities, and server-initiated input such as elicitation and sampling becomes a multi round-trip request. Spring AI 2.1 supports this "modern" protocol on both sides, on top of the MCP Java SDK 2.2.0 and next to the existing STDIO, SSE, Streamable HTTP and stateless servers and clients.
服务器Servers
设置 spring.ai.mcp.server.protocol=MODERN。你在其他协议中使用的相同 @McpTool、@McpResource、@McpPrompt 和 @McpComplete Bean 以及 ToolCallbacks,均可通过 WebMVC、WebFlux 或 STDIO 原样提供。两种 API 类型均受支持。设置 spring.ai.mcp.server.type=ASYNC 后,方法将返回 Mono,并通过 McpAsyncNotifier 报告进度:Set spring.ai.mcp.server.protocol=MODERN. The same @McpTool, @McpResource, @McpPrompt and @McpComplete beans and ToolCallbacks you use with the other protocols are served unchanged, over WebMVC, WebFlux or STDIO. Both API types are supported. With spring.ai.mcp.server.type=ASYNC, methods return a Mono and report progress through McpAsyncNotifier:
@McpTool(name = "index", description = "Indexes the given paths")
public Mono<String> index(McpAsyncNotifier notifier, @McpToolParam(description = "paths") List<String> paths) {
return Flux.range(0, paths.size())
.concatMap(i -> notifier.progress(i + 1, (double) paths.size(), paths.get(i)).then(index(paths.get(i))))
.then(Mono.just("Indexed " + paths.size() + " paths"));
}
方法可以通过返回 InputRequiredResult 来向用户请求输入,并使用 requiredCapabilities 声明其运行所必需的客户端能力。工具、资源和提示词可以在运行时添加和移除,客户端会通过订阅/监听获知相关变更。请参阅《MCP 2026-07-28 Servers》,其中还包含现有服务器的迁移说明。A method can answer with an InputRequiredResult to ask the user for input, and declare the client capabilities it cannot work without with requiredCapabilities. Tools, resources and prompts can be added and removed at runtime, and clients hear about it over subscriptions/listen. See MCP 2026-07-28 Servers, which also has migration notes for the existing servers.
客户端Clients
当 Streamable HTTP 连接的 protocol 属性表明其使用现代协议时,它就会使用该协议。旧版和现代连接可以并行工作,而一个工具回调提供程序会返回两者的工具:A Streamable HTTP connection speaks the modern protocol when its protocol property says so. Legacy and modern connections work side by side, and one tool callback provider returns the tools of both:
spring:
ai:
mcp:
client:
streamable-http:
connections:
billing:
url: http://localhost:8081
tickets:
url: http://localhost:8080
protocol: MODERN
现代客户端不持有会话,创建成本也很低,因此一个客户端可以对应单个调用方。连接的客户端作用域默认是 PER_REQUEST,因此每个 ChatClient 请求都会获得自己的客户端。SHARED 会为以单一身份调用服务器的应用程序保留一个客户端;CUSTOM 则允许由你提供的 bean 来选择客户端,例如为每个用户选择一个客户端。设置 listen=true 后,连接会实时获知工具变更;如果某个服务器无法访问,其工具会在冷却期内被排除,而不是导致请求失败。也支持 spring.ai.mcp.client.type=ASYNC。参见 MCP 2026-07-28 Connections。A modern client holds no session and is cheap to create, so a client can stand for a single caller. The client-scope of a connection is PER_REQUEST by default, so every ChatClient request gets its own client. SHARED keeps one client for an application that calls the server under a single identity, and CUSTOM lets a bean of yours select the client, for example one for each user. With listen=true the connection hears about tool changes as they happen, and the tools of a server that cannot be reached are left out for a cool-down period instead of failing the request. spring.ai.mcp.client.type=ASYNC is supported as well. See MCP 2026-07-28 Connections.
MCP 方面也有新内容Also new for MCP
- 一个通用的 McpServerCustomizer 可自定义每种服务器类型的服务器构建器和传输构建器。One generic
McpServerCustomizercustomizes the server and transport builders of every server type. - 可流式传输的 HTTP 服务器可以通过 maxSessions 和 sessionIdleTimeout 限制其会话状态。Streamable HTTP servers can cap their session state with
maxSessionsandsessionIdleTimeout. - MCP 注解可在 GraalVM 原生镜像中使用,并且无论 Bean 的创建顺序如何,带注解的服务器方法都会被注册。MCP annotations work in GraalVM native images, and annotated server methods are registered regardless of the order in which beans are created.
决策模型Decision Models
应用中的许多决策都有少数几个明确的结果:是或否、几个类别中的一个,或某个等级。聊天模型会用自由文本作答,你必须自行将其转换为可靠的结果。新的 DecisionModel API 专为这类决策而设计。你描述可能的结果,模型便会选出其中一个,并告知每种结果的可能性。Many decisions in an application have a small, known set of results: yes or no, one of a few categories, or a level on a scale. A chat model answers with free text, which you must turn into a reliable result yourself. The new DecisionModel API is made for these decisions. You describe the possible results, and the model picks one and tells you how likely each result is.
DecisionResponse response = decisionModel.call(DecisionPrompt.builder()
.text("My new headphones arrived yesterday, but the left side doesn't work. Can I get my money back?")
.question("defect", YesNoQuestion.builder()
.text("Does the customer report a defect?")
.whenYes("Part of the item does not work as it should")
.whenNo("The item works, and the message is about something else")
.build())
.question("satisfaction", ScoreQuestion.of("How satisfied is the customer?", "unhappy", "neutral", "happy"))
.build());
// open a repair ticket automatically only when the model is very sure
boolean defect = response.getYesNo("defect").isYes(0.9);
int satisfaction = response.getScore("satisfaction").getNearestLevel();
以下图表摘自参考文档,展示了同一个示例,并加入了第三个问题,询问消息的主题:提示词、对模型的一次调用、各个答案及其概率,以及代码从每个答案中读取的内容。这里的概率以及代码对结果的处理方式都只是示例。The following diagram, from the reference documentation, shows the same example with a third question, about the topic of the message: the prompt, the single call of the model, the answers with their probabilities, and what the code reads from each answer. The probabilities, and what the code does with the results, are examples.
由于答案会附带概率,因此由你的应用决定模型必须达到多高的置信度才能采取行动。典型用途包括分类、防护措施(例如在提示注入到达聊天模型之前将其拦截),以及日常业务逻辑。提供了三种实现方式,每种都会由 Boot starter 自动配置:Because the answer carries probabilities, your application decides how sure the model must be before it acts. Classification, guardrails such as stopping a prompt injection before it reaches a chat model, and everyday business logic are the typical uses. Three implementations are available, each auto-configured by a Boot starter:
- OpenAI:OpenAiDecisionModel,由 OpenAI Decisions API 提供支持,并在 spring.ai.openai.decision 下配置。OpenAI:
OpenAiDecisionModel, backed by the OpenAI Decisions API and configured underspring.ai.openai.decision. - Ollama:OllamaDecisionModel,默认模型为 d1-omni:600m。它在你的本地机器上运行,无需 API 密钥,是体验该 API 最快捷的方式。Ollama:
OllamaDecisionModel, withd1-omni:600mas the default model. It runs on your machine and needs no API key, which makes it the quickest way to try the API. - System One:SystemOneDecisionModel,适用于所有支持 System One 协议的服务器,例如 TypeSafe、Laya、llmman 和 Ollama。该协议的客户端属于 Spring AI 的一部分,位于 spring-ai-systemone 中;新的 spring-ai-starter-model-systemone starter 会在 spring.ai.systemone 下对其进行配置。System One:
SystemOneDecisionModel, for every server that speaks the System One protocol, such as TypeSafe, Laya, llmman and Ollama. The client of the protocol is part of Spring AI, inspring-ai-systemone, and the newspring-ai-starter-model-systemonestarter configures it underspring.ai.systemone.
其他 Spring AI 功能构建于该 API 之上:Other Spring AI features are built on the API:
- RAG。DecisionDocumentReranker 会通过判断每份检索到的文档是否回答了查询,对文档重新排序。DecisionDocumentFilter 会在文档进入提示词之前,筛查其中的提示注入、矛盾内容和相关性。RAG.
DecisionDocumentRerankerreorders the retrieved documents by asking whether each one answers the query.DecisionDocumentFilterscreens them for prompt injection, contradictions and relevance before they reach the prompt. - 工具搜索。DecisionToolIndex 会询问决策模型哪个已索引的工具最适合满足请求,以及是否有工具适用,这样就可以报告没有合适的工具,而不是返回一个最接近但不正确的工具。Tool search.
DecisionToolIndexasks a decision model which indexed tool best serves the request and whether any tool applies at all, so it can report that no tool fits instead of returning the nearest wrong one.
在决策模型基础上构建Building on Decision Models
社区维护的 Spring AI Decision Extensions 项目在 API 之上提供了现成的构建模块。它仅依赖于 DecisionModel,因此可与三种实现中的任意一种配合使用:The community-maintained Spring AI Decision Extensions project provides ready-made building blocks on top of the API. It depends only on DecisionModel, so it works with each of the three implementations:
- DecisionJudge:一种由多个狭义评判标准构成的模型即评审器,每项标准都有各自的阈值,并在一次调用中全部作答。
DecisionJudge: a model-as-a-judge made of narrow criteria, each with its own threshold, all answered in one call. - DecisionSelfRefineAdvisor:一种会评判每条聊天回复,并在回复不够理想时将缺陷作为反馈再次调用模型的顾问。
DecisionSelfRefineAdvisor: an advisor that judges every chat response and, when it falls short, calls the model again with the defect as feedback. - DecisionGuardrailAdvisor:根据一组风险对用户消息和回复进行筛查的顾问,每段文本各进行一次决策调用。其拒绝会标记为 GuardrailRefusal,详见下文“Guardrail refusals”。
DecisionGuardrailAdvisor: advisors that screen the user message and the reply against a set of hazards, with one decision call for each text. Their refusals are marked as aGuardrailRefusal, described under "Guardrail refusals" below. - 针对答案采取行动的模式:是采取行动、确认还是升级处理;答案在不同调用之间的差异程度;以及将多个分数加权合并为一个分数。Patterns for acting on answers: whether to act, confirm or escalate, how much the answers vary between calls, and several scores weighed into one.
参考文档中的“基于决策模型构建”展示了一个将这些模型组合起来的 ChatClient。Building on Decision Models in the reference documentation shows a ChatClient that combines them.
更丰富的消息模型A richer message model
消息部分Message Parts
在 2.0 之前,Spring AI 消息由文本以及工具调用和媒体的附属列表构成。这种结构无法表示当前模型返回的内容:与工具调用交错的推理、图片之间的文本,或必须在下一轮原样传回的提供商特定内容块。Until 2.0, a Spring AI message was a text plus side lists of tool calls and media. That shape cannot represent what current models return: reasoning interleaved with tool calls, text between images, or provider-specific blocks that must be sent back unchanged on the next turn.
AssistantMessage、UserMessage 和 ToolResponseMessage 现在将其内容保存为有序的 MessagePart 条目列表:TextPart、ReasoningPart、ToolCallPart、ToolResultPart、MediaPart 和 UnknownPart。各部分会保留提供方生成它们时的顺序。ReasoningPart 或 ToolCallPart 可以携带 OpaquePayload,例如 Anthropic 思考签名或 Gemini 思维签名,并在重放时保持原样。UnknownPart 会保留适配器尚未建模的区块的原始 JSON,因此不会有任何内容被悄然丢弃。AssistantMessage, UserMessage and ToolResponseMessage now hold their content as an ordered list of MessagePart entries: TextPart, ReasoningPart, ToolCallPart, ToolResultPart, MediaPart and UnknownPart. Parts keep the order the provider produced them in. A ReasoningPart or ToolCallPart can carry an OpaquePayload, such as an Anthropic thinking signature or a Gemini thought signature, that is replayed unchanged. UnknownPart keeps the raw JSON of a block an adapter does not model yet, so nothing is silently dropped.
UserMessage question = UserMessage.builder()
.part(TextPart.of("What changed between these two charts?"))
.part(MediaPart.of(firstChart))
.part(MediaPart.of(secondChart))
.build();
AssistantMessage answer = chatModel.call(new Prompt(question)).getResult().getOutput();
for (ReasoningPart reasoning : answer.getReasoning()) {
System.out.println("Reasoning: " + reasoning.text());
}
System.out.println(answer.getText());
核心项目中的所有聊天模型都以原生方式生成和使用消息片段:OpenAI(Chat Completions 和 Responses)、Anthropic、Google GenAI、Amazon Bedrock Converse、Ollama、Mistral AI 和 DeepSeek。熟悉的访问器(getText()、getMedia()、getToolCalls() 和新增的 getReasoning())都是消息片段的视图,因此现有代码仍能正常运行。《消息片段:往返传递后仍保留的推理》介绍了这一设计及其为各个模型带来的优势。All chat models of the core project produce and consume parts natively: OpenAI (Chat Completions and Responses), Anthropic, Google GenAI, Amazon Bedrock Converse, Ollama, Mistral AI and DeepSeek. The familiar accessors (getText(), getMedia(), getToolCalls() and the new getReasoning()) are views over the parts, so existing code keeps working. Message Parts: Reasoning That Survives the Round Trip explains the design and what each model gains.
OpenAI Responses APIOpenAI Responses API
新的 OpenAiResponsesChatModel 使用 OpenAI 的 /v1/responses 端点,与基于 Chat Completions 的 OpenAiChatModel 并列。从 GPT-5.4 开始,Chat Completions 不支持将工具调用与 none 以外的推理强度结合使用,而 Responses 支持。如果你要基于当前 OpenAI 旗舰模型构建智能体,应使用这个端点。切换只需设置一个属性:The new OpenAiResponsesChatModel talks to OpenAI's /v1/responses endpoint, next to the Chat Completions-based OpenAiChatModel. Starting with GPT-5.4, Chat Completions does not support tool calling combined with a reasoning effort other than none, while Responses does. If you build an agent on a current OpenAI flagship model, this is the endpoint to use. Switching is a single property:
# chat-completions (default) | responses
spring.ai.openai.chat.api=responses
Responses 回复中的每个条目都会按顺序成为一个部分,加密后的推理内容会在工具调用之间原样传回。模型是无状态的:每次调用都会发送完整的 Prompt,因此记忆、顾问和 RAG 的工作方式与 OpenAiChatModel 相同。HostedTool 启用由 OpenAI 在其端运行的工具:网页搜索、文件搜索、代码解释器、远程 MCP 和图像生成。请参阅 OpenAI Responses 参考页面。Each item of a Responses reply becomes one part, in order, and the encrypted reasoning content is handed back unchanged across tool calls. The model is stateless: every call sends the whole Prompt, so memory, advisors and RAG work as they do with OpenAiChatModel. HostedTool enables the tools OpenAI runs on its side: web search, file search, code interpreter, remote MCP and image generation. See the OpenAI Responses reference page.
工具调用参数流式传输Tool call argument streaming
模型会逐段流式传输工具调用的参数。Anthropic、OpenAI(两个 API)、Bedrock Converse 和 DeepSeek 现在会将这些增量作为标记为 partial 的 ToolCallParts 进行流式传输,因此 UI 可以在模型仍在编写工具调用时显示它。完整调用随后仍会以相同的索引出现。partial 部分并不是工具调用:getToolCalls() 和工具调用循环会跳过它,而且它永远不会存入内存。Models stream the arguments of a tool call piece by piece. Anthropic, OpenAI (both APIs), Bedrock Converse and DeepSeek now stream these deltas as ToolCallParts marked as partial, so a UI can show a tool call while the model is still writing it. The complete call still follows, at the same index. A partial part is not a tool call: getToolCalls() and the tool calling loop skip it, and it is never stored in memory.
结束原因类别Finish reason categories
各个提供商对模型停止原因的命名各不相同:stop、end_turn、STOP、content_filter、SAFETY 等。现在,每个 Generation 除了报告原始结束原因外,还会报告一个 FinishReasonCategory,该类别在所有提供商之间保持一致:COMPLETED、TRUNCATED、TOOL_CALL、FILTERED、OTHER 或 UNSPECIFIED。Providers name the reason a model stopped differently: stop, end_turn, STOP, content_filter, SAFETY and so on. Next to the raw finish reason, every Generation now reports a FinishReasonCategory that is the same for every provider: COMPLETED, TRUNCATED, TOOL_CALL, FILTERED, OTHER or UNSPECIFIED.
ChatGenerationMetadata metadata = chatResponse.getResult().getMetadata();
if (metadata.getFinishReasonCategory() == FinishReasonCategory.FILTERED) {
// a safety filter stopped the answer, or the model refused to answer
}
智能体的构建模块Building blocks for agents
模型本身只负责预测文本。让它成为智能体的,是围绕它构建的运行框架:循环、工具、记忆、权限和检查机制。参考文档新增的 Agents 页面将这些职责分别映射到 Spring AI。其中有几项是 2.1 中新增的。A model on its own only predicts text. What turns it into an agent is the harness around it: the loop, the tools, the memory, the permissions and the checks. The new Agents page of the reference documentation maps each of these responsibilities to Spring AI. Several of them are new in 2.1.
会话 APISession API
ChatMemory 会为每个 conversation id 存储一份扁平的消息列表。对于长对话和智能体来说,这还不够,因此 Spring AI 现在引入了 Session API,该 API 移植自社区的 Spring AI Session 项目。一个 session 会将对话保存为只追加的事件日志。作为 Session 的首个用途,会话记忆会基于该日志的一个视图构建提示词:ChatMemory stores a flat list of messages per conversation id. Long conversations and agents need more than that, so Spring AI now includes the Session API, ported from the community Spring AI Session project. A session keeps a conversation as an append-only log of events. Session memory, its first use, builds the prompt from a view of that log:
- 结构化事件。每条消息都是一个 SessionEvent,并连同其所有消息部分一起存储。自定义事件类型可以记录同一日志中发生的其他事情。Structured events. Every message is a
SessionEvent, stored with all its message parts. Event types of your own can record what else happened in the same log. - 回合感知压缩。触发条件决定历史记录何时变得过长,策略则决定哪些内容从视图中移除,并可选择为移除的内容生成摘要。压缩总是在回合边界处截断,因此模型不会看到没有对应结果的工具调用。它不会重写日志,而是追加一个边界,从此界定视图的内容。Turn-aware compaction. Triggers decide when the history has grown too large, and a strategy decides what leaves the view, optionally with a summary of what is dropped. A compaction always cuts on a turn boundary, so the model never sees a tool call without its result. It never rewrites the log: it appends a boundary that defines the view from then on.
- 回忆。压缩从视图中移除的内容仍保留在日志中。SessionService.searchEvents 可以通过关键词搜索再次找到这些内容,而 SessionRecallTools 则向模型提供与 conversation_search 工具相同的搜索功能。Recall. What a compaction takes out of the view stays in the log.
SessionService.searchEventsfinds it again with a keyword search, andSessionRecallToolsgives the model the same search as theconversation_searchtool. - 一个仓库 SPI。JdbcSessionRepository 支持 PostgreSQL、MySQL、MariaDB、Microsoft SQL Server 和 H2,并支持幂等且经过版本检查的追加操作。你也可以使用 spring-ai-test 中的契约测试来验证自定义存储实现。A repository SPI.
JdbcSessionRepositorysupports PostgreSQL, MySQL, MariaDB, Microsoft SQL Server and H2, with idempotent, version-checked appends. A store of your own can be verified against the contract tests inspring-ai-test.
添加 spring-ai-starter-model-session-jdbc starter,注册会话顾问,并在每次调用时传入会话 ID:Add the spring-ai-starter-model-session-jdbc starter, register the session advisors, and pass a session id with every call:
@Bean
ChatClient chatClient(ChatModel chatModel, SessionService sessionService) {
return ChatClient.builder(chatModel)
.defaultAdvisors(SessionAdvisors.builder(sessionService)
.compaction(new TurnCountTrigger(20), WindowCompactionStrategy.builder().lastTurns(10).build())
.build())
.defaultTools(SessionRecallTools.builder(sessionService).build())
.build();
}
String answer = chatClient.prompt()
.user("What did we decide about the invoice?")
.advisors(SessionAdvisors.session(sessionId))
.toolContext(Map.of(SessionRecallTools.SESSION_ID_CONTEXT_KEY, sessionId))
.call()
.content();
顾问自身不保存任何状态,因此应用程序的任意实例都可以运行会话中的任意一轮。这里有意不提供默认会话,因为共享会话会在不知不觉中合并不同用户的历史记录。“扩展点”页面介绍了库如何记录自身事件,以及如何将顾问置于会话顾问的外围。The advisors keep no state of their own, so any application instance can run any turn of a session. There is deliberately no default session, since a shared one would silently merge the histories of different users. The Extension Points page describes how a library records events of its own and places advisors around the session advisors.
ChatMemory、其顾问类和仓库类已弃用,将在 3.0.0 中移除。每项弃用都会注明替代项,而“Chat Memory to Session Memory”会将一个 API 映射到另一个 API。VectorStoreChatMemoryAdvisor 会保留,因为目前 Session Memory 还没有语义回忆功能的对应项。
ChatMemory, its advisors and its repositories are deprecated, for removal in 3.0.0. Each deprecation names its replacement, and Chat Memory to Session Memory maps one API onto the other.VectorStoreChatMemoryAdvisorstays, since sessions have no semantic recall counterpart yet.
工具调用确认Tool call confirmation
预订航班、删除文件或发送电子邮件,都可能是人们希望先行批准的操作。现在,工具可以为此请求批准:Booking a flight, deleting a file or sending an email are actions a person may want to approve first. A tool can now ask for that:
@Tool(description = "Book a flight", requiresConfirmation = true)
String bookFlight(String flightNumber) {
return bookingService.book(flightNumber);
}
当模型调用此类工具时,工具调用循环会在执行回复中的任何调用之前暂停,并将包含待决策调用的回复返回给你的应用程序。你的应用程序会为每次调用收集一个 ToolCallDecision,使用 ToolCallingManager.executeToolCalls(prompt, reply, decisions) 执行这些调用,并将结果作为下一次请求发送。循环在等待期间不会保留状态:prompt 和暂停的 reply 包含了继续所需的一切,因此只要你的应用程序保存了它们,重启后仍可恢复暂停的流程。ToolCallConfirmationPolicy 决定哪些调用需要确认:可以根据工具的元数据、对于你不拥有的工具(例如 MCP 工具)根据名称,或通过检查参数来判断。当用户转而继续操作而非作出决定时,会话记忆会处理那些因暂停而未获得结果的工具调用。请参阅“工具调用确认”。When the model calls such a tool, the tool calling loop pauses before any call of the reply runs, and the reply goes back to your application with the calls that wait for a decision. Your application collects a ToolCallDecision per call, runs them with ToolCallingManager.executeToolCalls(prompt, reply, decisions), and sends the results as its next request. The loop keeps no state while it waits: the prompt and the paused reply hold everything needed to continue, so a pause survives a restart if your application stores them. A ToolCallConfirmationPolicy decides which calls need confirmation: by the tool's metadata, by name for tools you do not own, such as MCP tools, or by inspecting the arguments. Session memory answers the tool calls that a pause left without a result when the user moves on instead of deciding. See Tool Call Confirmation.
工具调用限制Tool call limits
永不结束的循环是一种代价高昂的故障。工具调用循环现在会限制每种工具的调用次数以及单轮中的总调用次数,默认分别为 40 和 150,可通过 spring.ai.tools.limits.* 配置。达到限制时,循环会以 ToolCallLimitExceededException 结束,或者告知模型已达到限制并让它继续执行。Token 用量会在循环的所有轮次中累计。A loop that never ends is an expensive failure. The tool calling loop now limits the calls per tool and the total calls of a turn, 40 and 150 by default, configurable under spring.ai.tools.limits.*. When a limit is reached, the loop either ends with a ToolCallLimitExceededException or tells the model that the limit was reached and lets it continue. Token usage is accumulated across all rounds of the loop.
护栏拒绝Guardrail refusals
当护栏阻止某个请求时,它会返回一条拒绝回复,代替模型的回答。此类回复现在会标记为 GuardrailRefusal,顾问链的其余部分也会据此处理:StructuredOutputValidationAdvisor 不会再次请求模型,SemanticCacheAdvisor 不会缓存该回复,而 ChatClient.entity(...) 会抛出 GuardrailRefusalException。该异常继承自新的 ContentFilteredException;当提供方的安全过滤器拦截了响应,导致无法将其转换时,entity(...) 就会抛出此异常。两种情况都可以用同一个 catch 捕获:When a guardrail blocks a request, it returns a refusal in place of the model's answer. Such a reply is now marked as a GuardrailRefusal, and the rest of the advisor chain treats it accordingly: StructuredOutputValidationAdvisor does not ask the model again, SemanticCacheAdvisor does not cache it, and ChatClient.entity(...) throws a GuardrailRefusalException. That exception extends the new ContentFilteredException, which entity(...) throws for a response that a provider's safety filter stopped and that cannot be converted. One catch covers both:
try {
Order order = chatClient.prompt().user(message).call().entity(Order.class);
}
catch (ContentFilteredException ex) {
reply("Sorry, I can't help with that.");
}
向量存储与检索增强生成(RAG)Vector stores and RAG
你自己的嵌入向量Your own embeddings
VectorStore.add() 始终使用存储自身的嵌入模型计算嵌入。有时你已经有了向量:批处理 API 在夜间计算出了它们,另一个团队负责嵌入流水线,或者多模态模型为图像生成了嵌入。VectorStore.upsert() 会按原样存储向量,而 similaritySearch(float[], SearchRequest) 则使用你自行计算的查询向量进行搜索:VectorStore.add() always computes embeddings with the store's own embedding model. Sometimes you already have the vectors: a batch API computed them overnight, another team owns the embedding pipeline, or a multimodal model embedded an image. VectorStore.upsert() stores a vector as given, and similaritySearch(float[], SearchRequest) searches with a query vector you computed yourself:
vectorStore.upsert(List.of(new EmbeddedDocument(document, embedding)));
List<Document> results = vectorStore.similaritySearch(queryEmbedding,
SearchRequest.builder().topK(5).similarityThreshold(0.7).build());
再次写入相同的 id 会替换该行,因此使用稳定 id 的数据导入作业可以安全地重新运行。每个向量都会在写入任何内容之前,与索引的维度进行校验,而且存储的嵌入模型不会生成任何嵌入。这两项操作均由 pgvector、Qdrant、Redis、Elasticsearch、OpenSearch、Neo4j、MongoDB Atlas、Typesense、MariaDB、Chroma 和 Couchbase 实现。《在 Spring AI 2.1 中使用自有嵌入》通过一个示例对此进行了讲解。Writing the same id again replaces the row, so an ingestion job with stable ids can be re-run safely. Every vector is checked against the width of the index before anything is written, and the store's embedding model does not embed anything. Both operations are implemented by pgvector, Qdrant, Redis, Elasticsearch, OpenSearch, Neo4j, MongoDB Atlas, Typesense, MariaDB, Chroma and Couchbase. Using Your Own Embeddings in Spring AI 2.1 walks through an example.
较小的新增内容Smaller additions
- TokenTextSplitter 支持块重叠。该功能需主动启用;未启用时,分块结果与之前相同。
TokenTextSplittersupports chunk overlap. It is opt-in, and chunks are the same as before without it. - PagePdfDocumentReader 现已支持页码范围,Tika 文档读取器则升级至 Tika 4.0.0。
PagePdfDocumentReaderaccepts page ranges, and the Tika document reader moves to Tika 4.0.0. - PgVectorStore 可以使用具有不同列名的现有表。
PgVectorStorecan use an existing table with different column names. - MongoDBAtlasVectorStore 可以通过 bulkUpsertBatchSize 批量写入 upsert 操作。
MongoDBAtlasVectorStorecan write upserts in bulk withbulkUpsertBatchSize. - MilvusVectorStore 可以限定在特定分区内。
MilvusVectorStorecan be scoped to partitions. - Redis 向量存储自动配置支持通过 Bean 添加自定义元数据字段。The Redis vector store auto-configuration accepts custom metadata fields contributed as a bean.
模型和模态Models and modalities
- OpenAI。语音和转录支持流式传输,语音模型提供 instructions 选项。OpenAiChatModel 会填充速率限制元数据,并传递每次调用的请求头。OpenAiConnectionDetails bean 使 Testcontainers 或 Docker Compose 能够在开发和测试中提供与 OpenAI 兼容的服务器连接。OpenAI. Speech and transcription support streaming, and the speech model has an
instructionsoption.OpenAiChatModelpopulates rate-limit metadata and propagates per-call headers. AnOpenAiConnectionDetailsbean lets Testcontainers or Docker Compose supply the connection to an OpenAI-compatible server in development and tests. - Anthropic。升级到 Anthropic Java SDK 3.x。重放工具调用时会保留思考块,提示缓存也涵盖引用文档。Anthropic. Moves to the Anthropic Java SDK 3.x. Thinking blocks are preserved when tool calls are replayed, and prompt caching covers citation documents.
- Google GenAI。新增图像生成、文本转语音和转录模型,以及聊天模型对 ToolChoice 的支持。Google GenAI. New image generation, text-to-speech and transcription models, and
ToolChoicesupport for the chat model. - Amazon Bedrock Converse。一小时的缓存 TTL、缓存的工具结果、工具重放时保留的推理内容,以及遵循 AWS SDK 默认规则的区域解析。Amazon Bedrock Converse. A one-hour cache TTL, cached tool results, reasoning content that is preserved on tool replay, and region resolution that follows the default rules of the AWS SDK.
- DeepSeek 的思考和 reasoningEffort 选项。DeepSeek.
thinkingandreasoningEffortoptions. - Mistral AI。审核功能转由 Mistral Moderation 2 负责。Mistral AI. Moderation moves to Mistral Moderation 2.
- Qxotic jinfer。感谢 Qxotic AI 团队,社区维护的 jinfer 集成提供可在 JVM 中运行的聊天、嵌入、文本转语音和转录模型。Qxotic jinfer. Thanks to the Qxotic AI team, the community-maintained jinfer integration provides chat, embedding, text-to-speech and transcription models that run inside the JVM.
聊天模型比较页面展示了每个提供商支持的功能。The Chat Model Comparison page shows what each provider supports.
可观测性Observability
- 文本转语音模型(OpenAI、ElevenLabs、Google GenAI)、转录模型(OpenAI、Google GenAI)以及 Stability AI 图像生成,均像聊天和嵌入模型一样通过 Micrometer 进行观测。Text-to-speech models (OpenAI, ElevenLabs, Google GenAI), transcription models (OpenAI, Google GenAI) and Stability AI image generation are observed with Micrometer, like chat and embedding models.
- 图像模型现在也会生成 gen_ai.client.token.usage 指标。Image models now also produce the
gen_ai.client.token.usagemetric. - 决策模型调用会被监控,并记录令牌使用量指标。Decision model calls are observed, with token usage metrics.
- Anthropic 和 Bedrock Converse 的提示词令牌数包含从提示缓存中读取和写入的令牌。The prompt tokens of Anthropic and Bedrock Converse include the tokens read from and written to the prompt cache.
- Anthropic 流式请求保留在调用方的跟踪链中,工具调用观测结果也会关联到正确的父级 Span。Anthropic streaming requests stay in the caller's trace, and tool call observations get the correct parent span.
可观测性页面介绍了每项观测结果,而新的指标参考文档则列出了各项指标及其标签。The Observability page describes every observation, and the new Metrics Reference lists the metrics and their tags.
新的参考文档New reference documentation
参考文档已围绕任务和概念重新整理,并根据 2.1 源代码进行了核对:The reference documentation was reorganized around tasks and concepts, and checked against the 2.1 source:
- 快速入门和四个教程:与文档对话、为模型提供工具、构建带会话功能的对话应用,以及构建和使用 MCP 服务器。A Quickstart and four tutorials: Chat with Your Documents, Give the Model Tools, A Conversational App with Sessions and Build and Use an MCP Server.
- ChatClient、工具调用、记忆、RAG、MCP、智能体、评估、可观测性和弹性等核心功能各自设有独立章节。模型 API、集成和升级指南则与它们分开。Core features such as ChatClient, tool calling, memory, RAG, MCP, agents, evaluation, observability and resilience each have their own section. Model APIs, integrations and upgrade guides are separate from them.
- 由社区维护的项目会标注为此类项目,而“社区维护的集成”页面会介绍这些项目的支持和安全条款。Community-maintained projects are labelled as such, and the Community-Maintained Integrations page describes their support and security terms.
- 旧结构中的每个页面都会重定向到其新位置。Every page of the old structure redirects to its new location.
安全性与可靠性Security and reliability
此版本修复的 CVE】【。CVEs fixed in this release
Spring AI 2.1.0 修复了以下 CVE。Spring AI 2.0.3 也已发布,并在 2.0.x 系列中修复了这些问题。Spring AI 2.1.0 fixes the following CVEs. Spring AI 2.0.3 is available as well and fixes them on the 2.0.x line.
- CVE-2026-59336 - spring-ai-bedrock-converse URLValidator 中不完整的 SSRF 阻止列表
- CVE-2026-59337 - 完整提示词以 WARN 级别记录
- CVE-2026-59338 - 不受限制的 Tika 文本提取可能耗尽 JVM 内存
- CVE-2026-59339 - FilterExpressionTextParser 中的非受控递归导致拒绝服务
- CVE-2026-59340 - 通过特制 PDF 在 PagePdfDocumentReader 中造成拒绝服务
- CVE-2026-59344 - 用户可控的筛选键可绕过 Coherence 元数据筛选
- CVE-2026-59345 - 通过正则表达式递归导致的拒绝服务
- CVE-2026-59348 - RedisChatMemoryRepository 查询方法中的转义不完整
- CVE-2026-59361 - RedisFilterExpressionConverter 中的 RediSearch 查询注入和租户隔离绕过
- CVE-2026-59369 - Typesense 向量存储筛选表达式注入绕过租户隔离
- CVE-2026-59415 - TypesenseVectorStore 中通过文档 ID 注入 doDelete 过滤器,导致意外删除文档
- CVE-2026-59417 - Spring AI Redis 语义缓存中的跨用户信息泄露与缓存投毒
- CVE-2026-59442 - TypesenseFilterExpressionConverter 中的逻辑分组表达式错误
2.1.0 的里程碑版本和候选发布版不包含这些修复,因此请从这些版本升级到 2.1.0。部分修复会改变行为,详见下文“从 2.0 升级”。The milestones and release candidates of 2.1.0 do not have these fixes, so upgrade from them to 2.1.0. Some of the fixes change behavior, see "Upgrading from 2.0" below.
Spring AI 2.0.1 又修复了七个 CVE,公告中列出了这些漏洞;所有这些修复也包含在 2.1.0 中。MCP 服务器传输机制不再将异常消息放入错误响应中。Spring AI 2.0.1 fixed seven more CVEs, listed in its announcement, and all of these fixes are part of 2.1.0 as well. The MCP server transports no longer put exception messages into error responses.
可靠性修复Reliability fixes
迁移到 2.0 的团队提供的反馈促成了许多修复,其中大多数与流式传输和工具调用有关:The feedback from teams who moved to 2.0 led to many fixes, most of them in streaming and tool calling:
- OpenAI 流式响应会按索引合并工具调用增量,报告 token 用量,并再次遵循配置的超时时间。取消流式响应后,不再泄漏 HTTP 响应。OpenAI streaming merges tool call deltas by index, reports token usage, and honors the configured timeout again. A cancelled stream no longer leaks the HTTP response.
- ToolCallingAdvisor 会保留 doBeforeCall 和 doBeforeStream 所做的更改,而 StructuredOutputValidationAdvisor 不再重复工具调用请求。
ToolCallingAdvisorkeeps the changes thatdoBeforeCallanddoBeforeStreammake, andStructuredOutputValidationAdvisorno longer repeats tool call requests. - OpenAI 严格模式适用于非 Spring AI 提供的工具架构,例如 MCP 工具架构。OpenAI strict mode works for tool schemas that do not come from Spring AI, such as MCP tool schemas.
- 顾问接受空上下文值。Advisors accept null context values.
- 文档读取器会关闭其资源流,并对格式错误的 PDF 进行处理。Document readers close their resource streams, and malformed PDFs are handled.
- 已修复 Milvus、Cassandra、Qdrant 和 SimpleVectorStore 的筛选器问题。Filters were fixed for Milvus, Cassandra, Qdrant and
SimpleVectorStore.
从 2.0 升级Upgrading from 2.0
Spring AI 2.1 基于 Spring Boot 4.2 构建,因此请同时升级两者。对于大多数应用,只需更新这两个版本即可。升级到 2.1 列出了可能需要留意的更改,另有专门的指南介绍如何迁移到 Anthropic Java SDK 3.x,以及如何从 Chat Memory 迁移到 Session Memory。Spring AI 2.1 is built on Spring Boot 4.2, so upgrade both together. For most applications, updating the two versions is all it takes. Upgrading to 2.1 lists the changes that may need attention, and dedicated guides cover the move to the Anthropic Java SDK 3.x and from Chat Memory to Session Memory.
如果你从 2.0.2 或更早版本升级,也请阅读 2.0.2 和 2.0.3 的说明,因为上述三项安全修复会改变行为:If you upgrade from 2.0.2 or earlier, also read the notes for 2.0.2 and 2.0.3, because three of the security fixes above change behavior:
- SemanticCacheAdvisor 需要一个 SemanticCacheScopeResolver,并且缓存响应仅在作用域相同的请求之间共享。只有当应用定义了一个 resolver bean 时,自动配置才会注册该 advisor。
SemanticCacheAdvisorrequires aSemanticCacheScopeResolver, and cached responses are shared only between requests of the same scope. The auto-configuration registers the advisor only when the application defines a resolver bean. - TikaDocumentReader 默认最多提取文档中的 10,000,000 个字符,文本更多时则会失败。
TikaDocumentReaderextracts at most 10,000,000 characters of a document by default, and fails for a document with more text. - Typesense 向量存储会将过滤值写成反引号字面量,并拒绝包含反引号的值。The Typesense vector store writes filter values as backtick literals and rejects values that contain a backtick.
来自 Spring AI 社区From the Spring AI Community
社区项目将 Spring AI 扩展到核心项目之外。它们由各自的作者维护,并按照各自的计划发布。关于这意味着什么,请参阅“支持与安全”。Community projects extend Spring AI beyond the core project. They are maintained by their own authors and released on their own schedule. See Support and Security for what that means.
- Spring AI Session 正在归档。它的核心、JDBC 存储库和顾问现已成为 Spring AI 2.1 的 Session API。后续的会话存储库和会话功能将在新的 Spring AI Session Extensions 社区项目中开发。该项目的首个版本 0.11.0 为每个会话新增了轮次状态,支持将工具调用确认保存在会话日志中并在任意实例上恢复,还新增了 Kafka 会话存储库。该项目目前处于实验阶段。Spring AI Session is being archived. Its core, its JDBC store and its advisors are now the Session API of Spring AI 2.1. The new Spring AI Session Extensions community project is where further session repositories and session features are built. Its first release, 0.11.0, adds a turn status for each session, tool call confirmations that are kept in the session log and resumed on any instance, and a Kafka session repository. The project is experimental.
- Spring AI TypeSafe 正在被归档,转而采用 Spring AI 2.1 的 DecisionModel API 以及全新的 Spring AI Decision Extensions 社区项目,该项目首次发布版本为 0.5.0。客户端、RAG 后处理器和工具索引已移入 Spring AI。评判器、自我精炼和护栏顾问以及相关模式已移至 Decision Extensions,详见上文“Decision Models”部分。Spring AI TypeSafe is being archived in favor of the
DecisionModelAPI of Spring AI 2.1 and the new Spring AI Decision Extensions community project, first released as 0.5.0. The client, the RAG post-processors and the tool index moved into Spring AI. The judge, the self-refine and guardrail advisors and the patterns moved to Decision Extensions, described in the Decision Models section above. - Spring AI Agent Utils 自 2.0 以来发布了 0.11.0 至 0.14.0:新增 Auto-Dream 记忆整合、可插拔的 ExecBackend(含用于沙箱执行的 Docker 后端)、用于控制智能体循环的 InterruptAdvisor 和 ToolCallListener,以及 GraalVM 原生镜像中的 classpath 技能。0.14.0 转向 Spring AI 2.1 及其 session 模块。Spring AI Agent Utils released 0.11.0 to 0.14.0 since 2.0: Auto-Dream memory consolidation, a pluggable
ExecBackendwith a Docker backend for sandboxed execution,InterruptAdvisorandToolCallListenerto control the agent loop, and classpath skills in GraalVM native images. 0.14.0 moves to Spring AI 2.1 and its session module. - Spring AI A2A 0.4.0 改用 A2A Java SDK 1.4.0.Final。Spring AI A2A 0.4.0 moves to the A2A Java SDK 1.4.0.Final.
- Spring AI ACP Harness Client 是一个新项目,为 Spring 应用提供统一的编程模型,以支持使用 Agent Client Protocol 的编码智能体,例如 Goose、Codex 和 OpenCode。Spring AI ACP Harness Client is a new project that gives a Spring application one programming model for coding agents that speak the Agent Client Protocol, such as Goose, Codex and OpenCode.
- MCP Security 0.1.14 通过验证 Origin 标头和颁发者 URL 来增强 MCP 服务器的安全性。MCP Security 0.1.14 hardens MCP servers with Origin header validation and issuer URL validation.
- Spring AI AgentCore 将 Spring AI 连接到 Amazon Bedrock AgentCore,涵盖运行时端点、身份、记忆、浏览器和代码解释器。Spring AI AgentCore connects Spring AI to Amazon Bedrock AgentCore: runtime endpoints, identity, memory, browser and code interpreter.
接下来呢?What's next
- Spring AI Agent。2.1 的 harness 功能服务于一个基于 ChatClient 构建的智能体。下一步是处理智能体在生产环境中的外围需求:组合多个智能体,每个智能体都拥有自己的模型、工具和权限;以类型化图的形式在代码中定义流程;以及支持在崩溃后恢复或等待人工介入后继续运行。我们计划在 12 月初将其作为独立项目发布,归入 Spring Projects Experimental,基于 Spring AI 2.1 构建,并于明年将其合并到 Spring AI 3.0 中。ChatClient 可以作为智能体运行,使用自己的 advisors 和工具调用循环;智能体也可以作为 ChatClient 的工具,因此现有应用可以逐步采用它。Spring AI Agent. The harness features of 2.1 serve one agent built with
ChatClient. The next step is what surrounds agents in production: composing several agents, each with its own model, tools and permissions, defining flows in code as typed graphs, and runs that resume after a crash or wait for a person. We plan to publish it in early December as a separate project under Spring Projects Experimental, built on Spring AI 2.1, and to merge it into Spring AI 3.0 next year. AChatClientcan run as an agent, with its advisors and its tool loop, and an agent can be a tool of aChatClient, so existing applications can adopt it step by step. - 会话存储和功能。目前仅有 ChatMemory 仓库的存储(如 Cassandra、Neo4j、MongoDB 和 Redis)将在 3.0.0 移除 ChatMemory 之前规划会话仓库。这些仓库将在 Spring AI Session Extensions 社区项目中构建,该项目将从 Kafka 仓库起步,并提供轮次状态等其他会话功能。Session stores and features. Session repositories for the stores that only have a
ChatMemoryrepository today, such as Cassandra, Neo4j, MongoDB and Redis, are planned beforeChatMemoryis removed in 3.0.0. They are built in the Spring AI Session Extensions community project, which starts with a Kafka repository, together with further session features such as the turn status. - MCP。目前,属性可以配置基于 JDK HttpClient、采用 Streamable HTTP 的 2026-07-28 客户端连接。计划于 12 月发布的 Spring AI 2.1.1 将补上缺失的 STDIO 和 WebClient 客户端传输方式。我们还在探索客户端和服务端两侧对两个协议版本的兼容支持:服务端既能响应旧版客户端,也能响应 2026-07-28 客户端;客户端连接则可与使用任一协议版本的服务端协同工作。除此之外,我们还会跟进该修订版的演进,在 MCP Java SDK 以及基于它构建的 Spring AI 抽象和注解中持续适配。MCP. Today, properties configure a 2026-07-28 client connection for Streamable HTTP on the JDK
HttpClient. Spring AI 2.1.1, planned for December, adds the missing STDIO and WebClient client transports. We are also exploring dual-era support on both sides: a server that answers legacy and 2026-07-28 clients alike, and a client connection that works with a server of either protocol. Beyond that, we will follow the revision as it evolves, in the MCP Java SDK and in the Spring AI abstractions and annotations built on it.
延伸阅读Further reading
- Spring AI 2.1 消息片段:往返传递后依然保留的推理内容
- 在 Spring AI 2.1 中使用你自己的嵌入模型
- Spring AI 模块化 RAG 与 TypeSafe Jev:检索更多,只保留能回答问题的内容。本文是为 TypeSafe Jev 撰写的。相同的后处理器现在分别是 DecisionDocumentReranker 和 DecisionDocumentFilter。Spring AI Modular RAG and TypeSafe Jev: Retrieve More, Keep Only What Answers. It was written for TypeSafe Jev. The same post-processors are now
DecisionDocumentRerankerandDecisionDocumentFilter. - 2.1.0-M1、2.1.0-RC1 和 2.1.0-RC2 的公告,其中对各项功能进行了更详细的介绍
贡献者Contributors
Spring AI 2.1 的发布离不开 Spring AI 团队和不断壮大的社区。感谢自 2.0.0 以来所有为此作出贡献的人:Spring AI 2.1 has been made possible by the Spring AI team and a community that keeps growing. Thank you to everyone who contributed since 2.0.0:
@56wj, @Ajax-1, @ashakirin, @Ashfaqbs, @Ayush0612005, @chabinhwang, @chaechaepower, @chemicL, @chengwudi1, @chensishang, @chuuminggg, @CodeTrainerMan, @CryoThrust, @Dennisadira, @dimitarproynov, @dlwldn30, @DragonFSKY, @draviteja, @durgadasepalli, @ericbottard, @EvanYao826, @fatan, @flex-ilsub, @gaoxiaolei-s59, @gh7035, @guanxuc, @herder, @hutiefang76, @ikaitist, @ilayaperumalg, @imgusguo, @iuliiasobolevska, @JamesBLewis, @jewoodev, @jhpark1227, @kamalcis, @Kehrlann, @kezhenxu94, @kimnamu, @lazer-dev, @leeworms, @lejuho, @liushenling2001, @Lubaoshuai, @martin-grofcik, @mdnayanmia31, @MKP999, @nicolaskrier, @OneZero-Y, @OreOreDa, @pengjonas, @pengmoubuaixuexi, @prachipanditrao, @pyg410, @quaff, @QuarkOS, @Rainmemery, @ralla0405, @rea9r, @rvullriede, @ryujungkyun, @sbrannen, @sdeleuze, @sdudzin, @sedhossein, @seeun0210, @seo92js, @Seol-JY, @sharanrenukeshbharmshetty, @sobychacko, @ss-bhatt, @stack3mpty, @strogiyotec, @subhashpolisetti, @thjanssen, @ThomasVitale, @TimurRakhmatullin86, @tzolov, @ultramancode, @vinayreddykalluri, @wantaekchoi, @xujiantop-crypto, @YashRL, @yyyCode, @ZhangDT-sky 和 @zxuhan@56wj, @Ajax-1, @ashakirin, @Ashfaqbs, @Ayush0612005, @chabinhwang, @chaechaepower, @chemicL, @chengwudi1, @chensishang, @chuuminggg, @CodeTrainerMan, @CryoThrust, @Dennisadira, @dimitarproynov, @dlwldn30, @DragonFSKY, @draviteja, @durgadasepalli, @ericbottard, @EvanYao826, @fatan, @flex-ilsub, @gaoxiaolei-s59, @gh7035, @guanxuc, @herder, @hutiefang76, @ikaitist, @ilayaperumalg, @imgusguo, @iuliiasobolevska, @JamesBLewis, @jewoodev, @jhpark1227, @kamalcis, @Kehrlann, @kezhenxu94, @kimnamu, @lazer-dev, @leeworms, @lejuho, @liushenling2001, @Lubaoshuai, @martin-grofcik, @mdnayanmia31, @MKP999, @nicolaskrier, @OneZero-Y, @OreOreDa, @pengjonas, @pengmoubuaixuexi, @prachipanditrao, @pyg410, @quaff, @QuarkOS, @Rainmemery, @ralla0405, @rea9r, @rvullriede, @ryujungkyun, @sbrannen, @sdeleuze, @sdudzin, @sedhossein, @seeun0210, @seo92js, @Seol-JY, @sharanrenukeshbharmshetty, @sobychacko, @ss-bhatt, @stack3mpty, @strogiyotec, @subhashpolisetti, @thjanssen, @ThomasVitale, @TimurRakhmatullin86, @tzolov, @ultramancode, @vinayreddykalluri, @wantaekchoi, @xujiantop-crypto, @YashRL, @yyyCode, @ZhangDT-sky and @zxuhan
开始使用Get started
在 start.spring.io 上试用 2.1,或升级现有应用。可以从快速入门或升级说明开始。如果发现问题,请提交 issue;如果想告诉我们接下来希望看到什么,请发起讨论。Try 2.1 on start.spring.io or upgrade an existing application, starting with the Quickstart or the upgrade notes. Open an issue if something is broken, or start a discussion to tell us what you would like to see next.
干杯!Cheers!
资源Resources
项目页面 | GitHub | 问题跟踪 | 参考文档Project Page | GitHub | Issues | Reference documentation