Skip to main content

Spring AI 2.0 to 2.1 Migration Guide: Deprecations, Breaking Changes and Upgrade Checklist

Upgrading Spring AI 2.0 to 2.1: what stops compiling, what silently behaves differently (Anthropic token counts, auth header, dropped temperature), the ChatMemory to session move, and a grep checklist plus OpenRewrite recipe, measured on 2.0.0 to 2.1.0 with fake models.

You bump spring-ai.version from 2.0.x to 2.1.0, the build goes green, and a week later somebody asks why Anthropic input tokens doubled on the cost dashboard, or why the temperature you set no longer does anything. That is the shape of this upgrade: very little stops compiling, and several things change quietly. This guide sorts every change that matters into those groups, shows before and after code, and ends with a grep script and an OpenRewrite recipe you can run on your own project. Where a claim is about behaviour, I ran it: the same test sources against Spring AI 2.0.0, 2.0.2, 2.0.3 and 2.1.0. If you are still on 1.x, start with Spring AI 1.x to 2.0: The Migration Guide.
Versions checked (3 December 2026). Spring AI 2.1.0 and 2.0.3 were announced on 20 November 2026, and both are on Maven Central. 2.1.0 is built on Spring Boot 4.2.0. Runs used JDK 25; the 2.0.x probes used Boot 4.1.0. No API key and no vendor call anywhere: chat models are scripted, or are the real Spring AI model classes pointed at a small local server I wrote. So this verifies what Spring AI sends and reports, not what Anthropic or OpenAI would answer. PostgreSQL with pgvector is real. All code: the ai-21-migration module.

Three kinds of change, and only one is loud

Think of an upgrade as three piles. The first is code that no longer compiles, which is annoying and safe. The second compiles and then behaves differently. The third is code that works today and is scheduled for removal. The picture below shows what lands where in 2.1.
1. Stops compilinga few removed membersone widened map typejavac finds all of them2. Compiles, behaves differentlytoken counts, auth header,dropped temperature,message shapes, exceptionsonly tests or dashboards notice3. Deprecated, removed in 3.0ChatMemory and its stores,old message metadata keys,runs today, warns todaySpend your review time on the middle box: nothing in the build will point at it.
To fill the piles I did not rely on the release notes alone. A small program, tools/ApiDiff.java, reads every non-starter jar in the 2.0.3 and 2.1.0 BOMs with the JDK class-file API and compares public and protected declarations. The headline from output/13-api-diff.txt:
# public API, Spring AI 2.0.3 -> 2.1.0 (tools/ApiDiff.java over every non-starter jar in the BOM)
REMOVED public types: 3
REMOVED public/protected members of types that still exist: 29
NEWLY @Deprecated (types and members that existed before): 62
Read the middle number with care. Several of those 29 “removed” members are auto-configuration factory methods whose parameter lists changed, or equals/hashCode overrides that are no longer declared on a message subclass. A removed declaration is a place to look, not proof that your code breaks. The three types gone are internal-looking: a Bedrock reasoning builder and two MCP bean post-processors. The full list is in the transcript.

The build change is small: bump Boot and the BOM together

The Spring AI BOM (bill of materials, the file that pins all Spring AI artifact versions for you) is imported separately from Spring Boot, so you move two numbers. Before, in the sample 2.0 project:
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>4.1.0</version>
  <relativePath/>
</parent>
<spring-ai.version>2.0.0</spring-ai.version>
Those lines come from legacy-app/pom.xml. After the upgrade, from pom.xml:
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>4.2.0</version>
  <relativePath/>
</parent>
<spring-ai.version>2.1.0</spring-ai.version>
What the BOM and the release tags say, compared by scripts/bom-diff.sh into output/15-bom-diff.txt:
# spring-ai-bom: managed artifacts
2.0.0: 161
2.0.3: 167
2.1.0: 181
# versions in the root pom.xml of each release tag
property                     2.0.0      2.0.3      2.1.0     
spring-boot.version          4.1.0      4.1.3      4.2.0      
anthropic-sdk.version        2.40.1     2.75.0     3.8.0      
openai-sdk.version           4.39.1     4.101.0    4.101.0    
com.google.genai.version     1.58.0     1.65.0     1.73.0     
mcp.sdk.version              2.0.0      2.1.0      2.2.0      
awssdk.version               2.41.22    2.55.14    2.55.14    
kotlin.version               2.3.20     2.3.20     2.4.21     
java.version                 17         17         17         
Compared with 2.0.3, the 2.1.0 BOM drops no artifact and adds 14: session memory (spring-ai-session, spring-ai-session-advisor, the JDBC modules and starter), decision models and the System One client, and Google GenAI speech and transcription.
The notes and the jar disagree on one version. The 2.1.0 upgrade notes and the Anthropic migration page say the Anthropic module uses Java SDK 3.4.0. The released spring-ai-anthropic 2.1.0 POM and the root POM of the v2.1.0 tag declare 3.8.0. If you pin the SDK yourself, or call it directly, check mvn dependency:tree rather than the prose.
Property renames: there are none against 2.0.3. I compared the Spring Boot configuration metadata inside the jars (scripts/config-diff.py). Nothing was removed; 20 properties became deprecated, 127 were added. From output/14-config-diff.txt:
# configuration metadata, Spring AI 2.0.3 -> 2.1.0
properties: old=957 new=1084

REMOVED: 0

NEWLY DEPRECATED: 20
  spring.ai.anthropic.chat.temperature
  spring.ai.anthropic.chat.top-k
  spring.ai.anthropic.chat.top-p
  spring.ai.chat.memory.repository.cassandra.initialize-schema
  spring.ai.chat.memory.repository.cassandra.keyspace
  spring.ai.chat.memory.repository.cassandra.messages-column
  spring.ai.chat.memory.repository.cassandra.table
The rename many people remember, spring.ai.chat.memory.redis.* to spring.ai.chat.memory.repository.redis.* together with a new artifact name, happened in 2.0.1. The old names still work there through a delegating module, and 2.1.0 deprecates the whole Redis chat memory anyway.
  • Two earlier modules in the same repository run 2.1.0 on Boot 4.1.x; that is a data point, not a support statement. The release is built against Boot 4.2.0.
  • The announcement says 2.1.0 and 2.0.3 both fix 13 CVEs, so staying on an older 2.0 patch is not a neutral choice.
  • Full property list: output/14-config-diff.txt.

Very little stops compiling

I wrote a tiny file for each of three removals or signature changes in the upgrade notes, and compiled all three against both versions with scripts/compile-breaks.sh. The sources are BedrockParams, DeepSeekPrefix and ThoughtKey, and the compiler output is output/07-compile-breaks.txt:
# javac on broken/src/*.java against two Spring AI versions

== Spring AI 2.0.3
BedrockParams.java: compiles
DeepSeekPrefix.java: compiles
ThoughtKey.java: compiles

== Spring AI 2.1.0
BedrockParams.java: FAILS
  BedrockParams.java:6: error: incompatible types: Map<String,String> cannot be converted to Map<String,Object>
DeepSeekPrefix.java: FAILS
  DeepSeekPrefix.java:4: error: cannot find symbol
    symbol:   method prefixAssistantMessage(String)
ThoughtKey.java: FAILS
  ThoughtKey.java:4: error: cannot find symbol
    symbol:   variable THOUGHT_METADATA_KEY
BrokeDo instead
Bedrock requestParameters is now Map<String, Object>Change the declared type of your variable; inline Map.of(..) literals are fine
DeepSeekAssistantMessage.prefixAssistantMessage(..)AssistantMessage.builder() with the DeepSeekChatModel.PREFIX_METADATA_KEY property
GoogleGenAiChatModel.THOUGHT_METADATA_KEY (the isThought key)response.getResult().getOutput().getReasoning()
One removal that was announced and did not happen. The 2.0.1 upgrade notes say the four-argument MCP tool callback constructors that take toolCallExceptionClass will be removed in 2.1.0. In the 2.1.0 jar, javap still shows SyncMcpToolMethodCallback(ReturnMode, Method, Object, Class), marked deprecated. It is still worth moving to the three-argument form, because the argument has been ignored since 2.0.1.
Two things are only partly source-compatible. A custom SemanticCache stops compiling if you jump from 2.0.1 or earlier (that change is from 2.0.2). And Anthropic users who call the vendor SDK directly face its own 2.x to 3.x changes, which the upgrade notes link to; I did not exercise direct SDK code.
  • Removed and re-signed members: output/13-api-diff.txt.
  • The DeepSeek streaming change (override chatCompletionStreamRaw, not chatCompletionStream) breaks test mocks at run time, not at compile time.

Anthropic prompt tokens now include the cache, and no compiler will tell you

Prompt caching lets a provider reuse the unchanged beginning of a prompt. The response then splits input into three parts: tokens processed normally, tokens written into the cache, and tokens read from it. The question is what Usage.getPromptTokens() means. It changed.
One request, as the server reports it: 50 uncached, 300 cache write, 2000 cache read2.0.0, 2.0.2promptTokens = 502.0.3, 2.1.0= 2350write 300cache read 2000A dashboard that still adds the cache counters to the new prompt count reports 4650:2300 tokens that were never sent. Subtract to get the uncached part; never add.
The diagram is drawn from a run, not from the notes. A local server returns fixed usage numbers, and the real AnthropicChatModel of each version reads them (AnthropicProbeTest). On 2.0.2, from output/01-usage-2.0.2.txt:
# Anthropic usage with cache tokens (Spring AI 2.0.2)
server reports: input_tokens=50 cache_creation=300 cache_read=2000 output=100
call()   promptTokens=50 completionTokens=100 totalTokens=150 cacheRead=2000 cacheWrite=300
call()   prompt + cacheRead + cacheWrite (the old workaround) = 2350
stream() promptTokens=50 completionTokens=100 totalTokens=150 cacheRead=null cacheWrite=null
stream() prompt + cacheRead + cacheWrite (the old workaround) = 50
The same source on 2.1.0, from output/01-usage-2.1.0.txt (2.0.3 prints the same numbers):
# Anthropic usage with cache tokens (Spring AI 2.1.0)
server reports: input_tokens=50 cache_creation=300 cache_read=2000 output=100
call()   promptTokens=2350 completionTokens=100 totalTokens=2450 cacheRead=2000 cacheWrite=300
call()   prompt + cacheRead + cacheWrite (the old workaround) = 4650
stream() promptTokens=2350 completionTokens=100 totalTokens=2450 cacheRead=2000 cacheWrite=300
stream() prompt + cacheRead + cacheWrite (the old workaround) = 4650
This change arrived in 2.0.3 as well as 2.1.0. It is listed under “Upgrading to 2.0.3” and applies to Anthropic and Bedrock Converse, for call and stream, and to the gen_ai.usage.input_tokens observation attribute. I ran the Anthropic model only; the Bedrock statement is from the notes. Also note what the 2.0.2 run shows: stream() reported no cache counters at all.
If anything in your code added the cache counters back, delete it. If you price requests, you now need the uncached part, which is a subtraction. This is the whole helper, UncachedTokens.java:
public final class UncachedTokens {

    private UncachedTokens() {
    }

    public static long of(Usage usage) {
        return usage.getPromptTokens() - orZero(usage.getCacheReadInputTokens()) - orZero(usage.getCacheWriteInputTokens());
    }

    private static long orZero(Long value) {
        return value == null ? 0 : value;
    }
}
Fed the 2.1.0 numbers it returns the 50 uncached tokens (output/12-uncached.txt):
promptTokens=2350 cacheRead=2000 cacheWrite=300 -> full-price input = 50
Budget alerts, per-tenant quotas and Grafana panels built on input_tokens will all step up on the day you deploy, with no change in traffic. Annotate the deploy.

Anthropic requests also change: no sampling settings, a different auth header, new thinking shape

2.1.0 moves to Anthropic API version 2026-10-21, which does not accept temperature, topP or topK. Spring AI keeps the methods so your code compiles, then discards the values. I set temperature(0.2) and looked at what left the process. On 2.0.3 (output/02-request-2.0.3.txt):
# What AnthropicChatModel sends, temperature=0.2 set (Spring AI 2.0.3)
header  no Authorization header
header  x-api-key: <key>
header  anthropic-version: 2023-06-01
body    "temperature":0.2
On 2.1.0 (output/02-request-2.1.0.txt):
# What AnthropicChatModel sends, temperature=0.2 set (Spring AI 2.1.0)
header  Authorization: Bearer <key>
header  no x-api-key header
header  anthropic-version: 2026-10-21
body    no temperature field
WARN org.springframework.ai.anthropic.AnthropicChatModel -- Anthropic API 2026-10-21 does not support temperature, topP or topK; ignoring temperature=0.2, topP=null, topK=null
WARN org.springframework.ai.anthropic.AnthropicChatModel -- Anthropic API 2026-10-21 does not support temperature, topP or topK; ignoring temperature=0.2, topP=null, topK=null
Check your proxy before you deploy. The API key now travels as Authorization: Bearer, not x-api-key. A gateway that injects or allow-lists x-api-key, an HTTP interceptor that rewrites it, or a log scrubber that masks only that header all need attention. The scrubber is the dangerous one: it can start logging keys.
Replies change shape too. A response with a thinking block used to be two generations; it is now one generation whose message holds ordered parts. Here is 2.0.0 (output/03-thinking-2.0.0.txt), 2.0.3 (output/03-thinking-2.0.3.txt) and 2.1.0 (output/03-thinking-2.1.0.txt) on the same reply:
# A reply with one thinking block and one text block (Spring AI 2.0.0)
getResults().size()                = 2
getResult().getOutput().getText()  = The user greets me.
generation 0: text=The user greets me.  metadata keys=[messageType, signature]
generation 1: text=Hello there.  metadata keys=[messageType]
# A reply with one thinking block and one text block (Spring AI 2.0.3)
getResults().size()                = 2
getResult().getOutput().getText()  = Hello there.
generation 0: text=Hello there.  metadata keys=[anthropicThinkingContents, messageType]
generation 1: text=The user greets me.  metadata keys=[messageType, signature]
# A reply with one thinking block and one text block (Spring AI 2.1.0)
getResults().size()                = 1
getResult().getOutput().getText()  = Hello there.
generation 0: text=Hello there.  metadata keys=[messageType]
On 2.0.0, getResult() returned the thinking text as if it were the answer. By 2.0.2 it returned the answer with the thinking in a second generation. On 2.1.0 there is one generation, and you read reasoning from getResult().getOutput().getReasoning(). Code that loops over getResults() looking for a signature metadata key now finds nothing on a non-streaming call. The notes also warn that thinking blocks in a chat memory written by an earlier version are lost on replay.
  • Delete the properties spring.ai.anthropic.chat.temperature, .top-p, .top-k and their legacy .options forms.
  • The WARN appears twice per first call above: once when the model is built, once for the request.

Messages are now lists of parts, so a few old habits stop working

A message used to be some text plus separate lists for media and tool calls. In 2.1 AssistantMessage and UserMessage hold one ordered list of parts (text, reasoning, tool call, media and so on), and the old getters are views over it. The notes say constructors keep working, and they do. Two behaviours change, measured by MessageAndGuardrailProbeTest. 2.0.3 first (output/04-messages-2.0.3.txt), then 2.1.0 (output/04-messages-2.1.0.txt):
# Message mutability and equality (Spring AI 2.0.3)
userMessage.getMedia().add(..)        returns true
assistant.getToolCalls().clear()      throws UnsupportedOperationException
same text, different image: equals()  = true
# Message mutability and equality (Spring AI 2.1.0)
userMessage.getMedia().add(..)        throws UnsupportedOperationException
assistant.getToolCalls().clear()      throws UnsupportedOperationException
same text, different image: equals()  = false
Code that appended an image to userMessage.getMedia() now throws; use the builder. And two messages that differ only in the attached image used to be equal, which matters if you deduplicate history or cache by message. getToolCalls() already refused mutation on 2.0.3. The protected fields textContent, media and responses are deprecated for subclasses.
  • Parts, streaming indices and provider signatures: Spring AI 2.1 Message Parts.
  • Streams can now carry partial tool-call parts with empty text; code that counts chunks will count more of them.

ChatMemory still runs, but it is on a clock

ChatMemory, MessageWindowChatMemory, the repositories, MessageChatMemoryAdvisor and their auto-configurations are deprecated for removal in 3.0.0. Session memory replaces them. Nothing changes at run time today. VectorStoreChatMemoryAdvisor is not deprecated.
ChatMemory (deprecated)conversation ida list of messagesa window deletes what it dropscopy onceSessionsession id (same context key)append-only log of eventsthe prompt is a view of the logOnly what the old memory still holds can be copied. Turns its window already dropped are gone.
The figure shows the one thing to plan for: this is a data move as well as a code change. First, what the compiler says. LegacyAssistant.java is ordinary 2.0 code:
public class LegacyAssistant {

    private final ChatClient chat;

    public LegacyAssistant(ChatModel model) {
        ChatMemory memory = MessageWindowChatMemory.builder()
                .chatMemoryRepository(new InMemoryChatMemoryRepository())
                .maxMessages(20)
                .build();
        this.chat = ChatClient.builder(model)
                .defaultAdvisors(MessageChatMemoryAdvisor.builder(memory).build())
                .build();
    }

    public String ask(String conversationId, String question) {
        return chat.prompt()
                .user(question)
                .advisors(a -> a.param(ChatMemory.CONVERSATION_ID, conversationId))
                .call()
                .content();
    }

    public static AnthropicChatOptions options() {
        return AnthropicChatOptions.builder()
                .model("claude-sonnet-4-5")
                .temperature(0.2)
                .build();
    }
}
Compiled on both versions (output/06-legacy-warnings.txt):
# javac -Xlint:deprecation,removal on probes/.../LegacyAssistant.java (from the Maven build log)
Spring AI 2.0.3: 0 warnings
Spring AI 2.1.0: 6 warnings
LegacyAssistant.java:[20,9] chat.memory.ChatMemory in chat.memory has been deprecated and marked for removal
LegacyAssistant.java:[21,43] chat.memory.InMemoryChatMemoryRepository in chat.memory has been deprecated and marked for removal
LegacyAssistant.java:[20,29] chat.memory.MessageWindowChatMemory in chat.memory has been deprecated and marked for removal
LegacyAssistant.java:[25,34] chat.client.advisor.MessageChatMemoryAdvisor in chat.client.advisor has been deprecated and marked for removal
LegacyAssistant.java:[32,40] chat.memory.ChatMemory in chat.memory has been deprecated and marked for removal
LegacyAssistant.java:[40,17] [removal] temperature(Double) in anthropic.AnthropicChatOptions.AbstractBuilder has been deprecated and marked for removal
The replacement is SessionAssistant.java:
public class SessionAssistant {

    private final ChatClient chat;

    public SessionAssistant(ChatModel model, SessionService sessions) {
        this.chat = ChatClient.builder(model)
                .defaultAdvisors(SessionAdvisors.builder(sessions).build())
                .build();
    }

    public String ask(String sessionId, String question) {
        return chat.prompt()
                .user(question)
                .advisors(SessionAdvisors.session(sessionId))
                .call()
                .content();
    }
}
It needs spring-ai-session-advisor (and spring-ai-starter-model-session-jdbc for a database). To carry live conversations over, I copy each one once with MemoryToSessionCopier.java:
public static int copy(ChatMemory from, SessionService to, String conversationId) {
    to.findOrCreate(CreateSessionRequest.builder().id(conversationId).build());
    if (!to.getEvents(conversationId).isEmpty()) {
        return 0;
    }
    int copied = 0;
    for (Message message : from.get(conversationId)) {
        if (message.getMessageType() != MessageType.SYSTEM) {
            to.appendMessage(conversationId, message);
            copied++;
        }
    }
    return copied;
}
Run against a window of five messages holding a system message and four turns (output/08-session-migration.txt, scripted model):
# Copying a ChatMemory conversation into a session (scripted model)
added to memory: 1 system message + 4 turns, maxMessages=5
memory holds:    system:Be brief. | user:question 3 | assistant:answer 3 | user:question 4 | assistant:answer 4
copied:          4 messages
copied again:    0 messages (already has events)
session holds:   user:question 3 | assistant:answer 3 | user:question 4 | assistant:answer 4
appendMessage(system): IllegalArgumentException: Storing a SystemMessage in session 'c2' is disabled. System prompts are configuration: supply them on every request (e.g. ChatClient defaultSystem/.system, or your own prompt builder) and keep per-session settings in Session.metadata. To store system messages anyway, use DefaultSessionService.builder().allowSystemMessages(true) or set spring.ai.session.allow-system-messages=true. See the "System Messages" reference page.
next prompt the model sees: user:question 3 | assistant:answer 3 | user:question 4 | assistant:answer 4 | user:question 5
ChatMemory.CONVERSATION_ID    = chat_memory_conversation_id
MemoryAdvisor.CONVERSATION_ID = chat_memory_conversation_id
Two traps in that transcript. The window had already thrown away turns 1 and 2, so no copier can bring them back. And a session refuses system messages by default: keep system prompts in defaultSystem, or set spring.ai.session.allow-system-messages=true. The context key did not change, so requests that set ChatMemory.CONVERSATION_ID reach the session advisor.
For JDBC, four properties have a declared replacement. The new tables are different tables, so changing the prefix alone moves no data.
DeprecatedReplacement
spring.ai.chat.memory.repository.jdbc.continue-on-errorspring.ai.session.repository.jdbc.continue-on-error
spring.ai.chat.memory.repository.jdbc.initialize-schemaspring.ai.session.repository.jdbc.initialize-schema
spring.ai.chat.memory.repository.jdbc.platformspring.ai.session.repository.jdbc.platform
spring.ai.chat.memory.repository.jdbc.schemaspring.ai.session.repository.jdbc.schema
Not everyone can move yet. There are no session stores yet for Cassandra, Neo4j, MongoDB or Redis, and no dialects for HSQLDB, Oracle or SQLite; both are described as planned before 3.0.0.
SQL Server: trust the jar. The 2.1.0 upgrade notes list SQL Server among the dialects still planned. The released spring-ai-session-jdbc 2.1.0 jar already contains SqlServerJdbcSessionRepositoryDialect and schema-sqlserver.sql, and the migration table in the reference documentation lists it as supported. I did not run it against a SQL Server.

Tool-call confirmation changes nothing until you ask, then it tests your wrappers

2.1.0 can pause the tool loop so a person approves a call. It is opt-in per tool: @Tool(requiresConfirmation = true), or a list of names in spring.ai.tools.confirmation.tools. Upgrading alone pauses nothing. The catch is for anyone with their own ToolCallingManager, for logging or metrics.
Model replyasks for refund(A-17)Loop pausesnothing has runyour code collects a yesResumeexecuteToolCalls(prompt,reply, decisions)The pause goes through the two-argument method, which an old wrapper does delegate.The resume goes through the new default method, which throws unless the wrapper overrides it.So the first half works in a demo and the second half fails when somebody clicks Approve.
As the figure shows, ToolCallingManager gained a three-argument executeToolCalls as a default method that throws. I ran a wrapper written for 2.0 and a corrected one, LoggingToolCallingManager.java, whose new method is:
public ToolExecutionResult executeToolCalls(Prompt prompt, ChatResponse response, ToolCallDecisions decisions) {
    log.info("resuming tool calls with {} decision(s)", decisions.decisions().size());
    return delegate.executeToolCalls(prompt, response, decisions);
}
The result (output/09-tool-manager.txt, from ToolManagerTest):
# A custom ToolCallingManager and a tool that requires confirmation (scripted model)
manager written for 2.0 (two methods)
  paused reply, awaiting [call_1], tool ran: []
  resume: UnsupportedOperationException: com.ankurm.aimigration.ToolManagerTest$Old does not support tool call decisions
LoggingToolCallingManager (three methods)
  paused reply, awaiting [call_1], tool ran: []
  resume: ok, tool ran: [A-17]
Also check how you read replies: a paused response often has empty text, so content() gives you no sign. Use chatResponse() and ToolCallDecisions.awaitingDecision(..).
  • Storing the pause, approver checks and replay protection: Human-in-the-Loop Tool Calls in Spring AI 2.1.
  • Related changes from 2.0.1: tools registered only as beans are no longer resolved by fallback, and calls per turn are capped (40 per tool, 150 total).

entity() throws different exceptions for blocked replies

When a content filter or a SafeGuardAdvisor blocks a reply, there is nothing to convert into your record. 2.0.x let the JSON parser fail. 2.1.0 says what happened. The lambda “model” below returns finishReason=content_filter; 2.0.3 (output/05-refusals-2.0.3.txt) then 2.1.0 (output/05-refusals-2.1.0.txt):
# entity() on a filtered reply and on a SafeGuardAdvisor refusal (Spring AI 2.0.3)
finishReason=content_filter, empty text
  entity(Answer.class)          throws MismatchedInputException
  responseEntity(..).entity()   throws MismatchedInputException
  content()                     returns ''
SafeGuardAdvisor blocks the word 'password'
  entity(Answer.class)          throws StreamReadException
  finishReason                  returns 'null'
# entity() on a filtered reply and on a SafeGuardAdvisor refusal (Spring AI 2.1.0)
finishReason=content_filter, empty text
  entity(Answer.class)          throws ContentFilteredException
  responseEntity(..).entity()   returns null
  content()                     returns ''
SafeGuardAdvisor blocks the word 'password'
  entity(Answer.class)          throws GuardrailRefusalException
  finishReason                  returns 'guardrailRefusal'
The class names are the whole story. A catch written for the parser exception no longer fires, and a global handler that maps parse failures to “retry” stops retrying. Catch ContentFilteredException; GuardrailRefusalException is a subtype and carries the refusal. content() behaves as before.
  • StructuredOutputValidationAdvisor no longer repeats a filtered response, and SemanticCacheAdvisor no longer caches a guardrail refusal (from the notes; not run here).
  • On streams, the refusal now has a finish reason, so BaseAdvisor after steps ahead of the guard run on it.

The OpenAI Responses API is opt-in, and its settings live somewhere else

2.1.0 supports OpenAI’s Responses API next to Chat Completions. It is not a breaking change: Chat Completions remains the default. The switch is one property, spring.ai.openai.chat.api=responses, and it swaps the bean. What it does not do is carry your spring.ai.openai.chat.* settings across. I started a real Boot context twice with the same model and temperature properties, pointed at a local server (OpenAiApiSwitchTest; output/10-openai-api-switch.txt):
# spring.ai.openai.chat.model=my-model and .temperature=0.1, with and without spring.ai.openai.chat.api (local fake server)
spring.ai.openai.chat.api unset
  bean:  OpenAiChatModel
  POST   /v1/chat/completions
  body:  model="my-model"  temperature=0.1
spring.ai.openai.chat.api = responses
  bean:  OpenAiResponsesChatModel
  POST   /v1/responses
  body:  model="gpt-5-mini"  temperature=(not sent)
A silent model change. With only the switch flipped, the request went to /v1/responses with gpt-5-mini, the default of the new model, and without the temperature. No error. Move settings to spring.ai.openai.responses.* (max-tokens becomes max-output-tokens).
The reference documentation also lists these for the Responses model: stop sequences, penalties, seed and n are ignored with a warning; requests are sent with store=false; reasoning continuity is preserved by the in-memory chat memory repository only; and many OpenAI-compatible servers do not implement /v1/responses at all. I did not test those.

VectorStore.upsert is new, optional, and not on every store

add() always embeds your text. The new upsert(List<EmbeddedDocument>) writes a vector you already have and replaces by id. It is a default method that throws, so nothing breaks, and a custom store only gains it if you implement it. The documentation lists pgvector, Redis, Elasticsearch, Qdrant, OpenSearch, Chroma, MariaDB, MongoDB Atlas, Typesense, Neo4j and Couchbase. SimpleVectorStore, the one in many tests, is not among them. The core of the test, against a real pgvector container with a counting fake embedding model (UpsertTest):
var store = PgVectorStore.builder(jdbc, embeddings).dimensions(3).initializeSchema(true).build();
store.afterPropertiesSet();
int before = embeddings.calls.get();
store.upsert(List.of(new EmbeddedDocument(new Document(id, "first version", Map.of("distance", 42)), new float[] { 0, 1, 0 })));
store.upsert(List.of(new EmbeddedDocument(new Document(id, "second version", Map.of("distance", 42)), new float[] { 0, 1, 0 })));
# VectorStore.upsert on SimpleVectorStore and on PgVectorStore (pgvector/pgvector:pg17)
SimpleVectorStore.upsert: UnsupportedOperationException: SimpleVectorStore does not support upsert
PgVectorStore.upsert twice, same id
  rows in vector_store:       1
  embedding model calls:      0
similaritySearch(float[], request)
  text:                       second version
  embedding model calls:      0
  stored metadata distance=42 reads back as: 42
  getScore():                 1.0
upsert with a 2-wide vector:  IllegalArgumentException: Embedding at index 0 has dimension 2 but the store expects dimension 3
That is output/11-upsert.txt. The same run covers a smaller 2.1.0 change in PgVectorStore: a metadata field of your own called distance used to be overwritten by the computed distance and is now preserved. If you read the computed value from metadata, use getScore(). Note also that the vector space is yours to keep consistent: a query from a different embedding model returns plausible nonsense with no error.
  • The 2.0.x behaviour of the distance key is taken from the upgrade notes; I ran 2.1.0 only for this test.

The checklist: grep first, then let OpenRewrite do the dull part

scripts/grep-checklist.sh takes a project directory and prints the lines that need a decision. On the sample 2.0 application, SupportBot plus its POM and properties (output/16-grep-checklist.txt):
# Spring AI 2.1 upgrade checklist: legacy-app

[ ] ChatMemory API: deprecated, removed in 3.0.0 (move to sessions)
      src/main/java/com/ankurm/legacy/SupportBot.java:11:    public String ask(ChatClient.Builder builder, ChatMemory memory, String user, String question) {
      src/main/java/com/ankurm/legacy/SupportBot.java:12:        return builder.defaultAdvisors(MessageChatMemoryAdvisor.builder(memory).build())
      src/main/java/com/ankurm/legacy/SupportBot.java:16:                .advisors(a -> a.param(ChatMemory.CONVERSATION_ID, user))
      src/main/java/com/ankurm/legacy/SupportBot.java:5:import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
      src/main/java/com/ankurm/legacy/SupportBot.java:6:import org.springframework.ai.chat.memory.ChatMemory;

[ ] Chat memory modules and properties
      pom.xml:47:      <artifactId>spring-ai-autoconfigure-model-chat-memory-redis</artifactId>

[ ] Chat memory properties (JDBC ones have spring.ai.session replacements)
      src/main/resources/application.properties:2:spring.ai.chat.memory.redis.host=localhost
      src/main/resources/application.properties:3:spring.ai.chat.memory.repository.jdbc.initialize-schema=always

[ ] Anthropic sampling options: discarded with a WARN on 2.1.0
      src/main/java/com/ankurm/legacy/SupportBot.java:24:                .temperature(0.2)
      src/main/java/com/ankurm/legacy/SupportBot.java:25:                .topK(40)

[ ] Anthropic sampling properties
      src/main/resources/application.properties:1:spring.ai.anthropic.chat.temperature=0.2

[ ] Token arithmetic on cache counters: prompt tokens include them since 2.0.3
      src/main/java/com/ankurm/legacy/SupportBot.java:31:        return usage.getPromptTokens() + usage.getCacheReadInputTokens() + usage.getCacheWriteInputTokens();

[ ] Spring AI and Spring Boot versions
      pom.xml:21:    <spring-ai.version>2.0.0</spring-ai.version>
      pom.xml:28:        <artifactId>spring-ai-bom</artifactId>
      pom.xml:29:        <version>${spring-ai.version}</version>
      pom.xml:9:    <artifactId>spring-boot-starter-parent</artifactId>

A hit is a place to read, not proof of a problem. No hit is not proof of safety.
OpenRewrite is a tool that edits source from a typed syntax tree. I found no Spring AI recipe in rewrite-spring 6.37.1, so rewrite.yml is a short one of my own. It deliberately leaves ChatMemory code alone. The code half:
name: com.ankurm.SpringAi20To21Code
displayName: Spring AI 2.0 to 2.1, the safe code edits
description: >
  Removes Anthropic sampling calls and moves the conversation-id constant. It does not move
  ChatMemory code to sessions: that needs a person.
recipeList:
  - org.openrewrite.java.RemoveMethodInvocations:
      methodPattern: org.springframework.ai.anthropic.AnthropicChatOptions$AbstractBuilder temperature(..)
  - org.openrewrite.java.RemoveMethodInvocations:
      methodPattern: org.springframework.ai.anthropic.AnthropicChatOptions$AbstractBuilder topP(..)
  - org.openrewrite.java.RemoveMethodInvocations:
      methodPattern: org.springframework.ai.anthropic.AnthropicChatOptions$AbstractBuilder topK(..)
  - org.openrewrite.java.ReplaceConstantWithAnotherConstant:
      existingFullyQualifiedConstantName: org.springframework.ai.chat.memory.ChatMemory.CONVERSATION_ID
      fullyQualifiedConstantName: org.springframework.ai.chat.client.advisor.api.MemoryAdvisor.CONVERSATION_ID
The diff for the Java file, and the check that both the before and after projects compile (output/17-openrewrite.txt, produced by scripts/openrewrite.sh):
compile before (Boot 4.1.0, Spring AI 2.0.0): ok
--- before/src/main/java/com/ankurm/legacy/SupportBot.java
+++ app/src/main/java/com/ankurm/legacy/SupportBot.java
@@ -3,6 +3,7 @@
 import org.springframework.ai.anthropic.AnthropicChatOptions;
 import org.springframework.ai.chat.client.ChatClient;
 import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
+import org.springframework.ai.chat.client.advisor.api.MemoryAdvisor;
 import org.springframework.ai.chat.memory.ChatMemory;
 import org.springframework.ai.chat.metadata.Usage;
 
@@ -13,7 +14,7 @@
                 .build()
                 .prompt()
                 .user(question)
-                .advisors(a -> a.param(ChatMemory.CONVERSATION_ID, user))
+                .advisors(a -> a.param(MemoryAdvisor.CONVERSATION_ID, user))
                 .call()
                 .content();
     }
@@ -21,8 +22,6 @@
     public AnthropicChatOptions options() {
         return AnthropicChatOptions.builder()
                 .model("claude-sonnet-4-5")
-                .temperature(0.2)
-                .topK(40)
                 .maxTokens(1024)
                 .build();
     }
compile after (Boot 4.2.0, Spring AI 2.1.0): ok

both recipes in one invocation, sampling calls left in SupportBot.java:
25:                .temperature(0.2)
26:                .topK(40)
Run the two recipes in two Maven invocations. In one invocation the types are still those of 2.0.0, where temperature is declared on a shared parent builder, so the pattern for Anthropic’s own builder matches nothing. It fails silently: the build stays green and the calls stay, as the last lines show. After the version bump, 2.1.0 declares the method on AnthropicChatOptions$AbstractBuilder and the same recipe removes it.
The line the recipe did not touch is the one that matters most: the sample’s billableInput method still adds the cache counters. Only the grep finds it.
1. 2.0.3behaviour first2. Build recipeversions, props3. Code recipeseparate run4. Compile, testcheck numbers5. Sessionsbefore 3.0.0Each step leaves a project that builds, so a failure has one suspect.
The order above is the one I would use. Going to 2.0.3 first isolates the token change from everything else; session migration can ship weeks later, because it is not required until 3.0.0.
  • Recipe source: rewrite.yml; sample input: legacy-app.
  • A hit from the grep is a place to read; no hit is not proof of safety, especially for wrappers written in other styles.

Everything else, by situation

Open the ones that apply to you. These come from the upgrade notes and the API diff; unless a transcript is linked, I did not run them.
Coming from 2.0.0, 2.0.1 or 2.0.2: changes you also inherit
  • 2.0.1: tools resolved from the application context are no longer executed unless attached to the request (spring.ai.tools.resolution.fallback.enabled=true restores it); per-turn tool call limits; ToolCallingAdvisor usage is accumulated across the loop; OpenAI tool strict mode defaults to false; OpenAI speech streaming emits real chunks; Media.Builder.data(Object) replaced by typed overloads; @McpTool checked exceptions and Errors now propagate; Mistral moderation categories and model constants changed.
  • 2.0.2: SemanticCacheAdvisor requires a SemanticCacheScopeResolver and old cache entries are not returned; custom SemanticCache implementations must add three methods; Neo4j chat memory indexes corrected (drop the two stale ones); new observations for speech, transcription and image models.
  • 2.0.3: prompt tokens include cache tokens (above); TikaDocumentReader stops at 10,000,000 characters with an IllegalStateException (pass -1 to remove the limit, for trusted files only); Typesense filter strings use backticks and reject values containing one.
Google GenAI, Bedrock, Mistral, DeepSeek and OpenAI-compatible servers
  • Google GenAI: one Generation per candidate; thoughts are ReasoningParts, so content() returns the answer.
  • Bedrock Converse: a non-streaming response is a single generation; streams emit extra reasoning chunks with empty text; unsigned reasoning survives replay only with the provider part attribute.
  • Mistral: text chunks are joined without a line separator; reasoning replay needs the provider attribute; ThinkChunk gains a signature component.
  • DeepSeek: DeepSeekAssistantMessage is deprecated; tool-only choices have an empty text instead of null.
  • OpenAI Chat Completions: reasoning is replayed as reasoning_content; set replayReasoningContent to false for a server that rejects it; unknown finish reasons are now passed through instead of null.
What is newly deprecated, grouped

Grouped from the 62 entries in output/13-api-diff.txt, which lists each one.

  • Chat memory: ChatMemory, MessageWindowChatMemory, ChatMemoryRepository, InMemoryChatMemoryRepository, MessageChatMemoryAdvisor, and the JDBC (with its dialects), Cassandra, MongoDB, Neo4j and Redis repositories, configs, auto-configurations and properties
  • Anthropic: temperature, topP, topK on options and properties; THINKING_METADATA_KEY, THINKING_TEXT_METADATA_KEY
  • Messages: protected fields AbstractMessage#textContent, AssistantMessage#media, UserMessage#media, ToolResponseMessage#responses
  • Providers: DeepSeekAssistantMessage, DeepSeekApi#chatCompletionStream(request, headers), MistralAiChatModel.THINKING_CONTENT_METADATA
  • MCP: McpSyncServerCustomizer, McpAsyncServerCustomizer and their two stateless variants. I found no mention of these four in the 2.1.0 upgrade notes; their Javadoc points to McpServerCustomizer
New in 2.1.0 that needs no action to upgrade
  • Decision models (DecisionModel, with OpenAI, Ollama and System One implementations).
  • Servers and clients for the stateless 2026-07-28 revision of the Model Context Protocol (spring.ai.mcp.server.protocol=MODERN). If you used it on 2.1.0-RC2, completions moved onto their prompt or template.
  • OpenAiConnectionDetails for pointing the OpenAI models at containers.
  • Finish reason categories.
What I did not verify
  • No real model provider was called; the fake servers return fixed replies.
  • Bedrock, Google GenAI, Mistral and DeepSeek runtime behaviour (only the three compile checks).
  • The Cassandra, Neo4j, MongoDB and Redis chat memory paths, and JDBC data migration between the old and new tables.
  • Streaming changes, MCP changes, and Gradle builds: the recipe was run with Maven only.

Should you upgrade now?

Yes for most 2.0 applications, with one afternoon of review. The compile surface is small and the security fixes ship in 2.0.3 and 2.1.0 alike. If you cannot take Boot 4.2 yet, or a proxy depends on x-api-key, or you rely on Anthropic sampling settings to shape output, go to 2.0.3 first and plan 2.1.0 separately. If your chat memory is on Redis, MongoDB, Cassandra or Neo4j, upgrade the framework but do not schedule the session move until a store exists or you are ready to write one. A new project should start on sessions.

Further reading

No Comments yet!

This site uses Akismet to reduce spam. Learn how your comment data is processed.