archive2026

Spring AI 2.0: my upgrade plan for a small service

Spring AI 2.0.0 was released on 12 June 2026 on top of Spring Boot 4. The order I would upgrade in, the breaking changes that hit a typical chat-plus-tools service, and what to test.

Spring AI 2.0.0 became generally available on 12 June 2026 (Spring blog). It is a big release. The baseline moves to Spring Boot 4 and Spring Framework 7, JSON moves to Jackson 3, and the options and tool calling APIs change.

I have one service to move. It is a typical small one: a ChatClient that talks to a local Ollama model, a few @Tool methods, an embedding model with a vector store, and a small MCP server. The full list of changes is in the official upgrade notes. This post is only the order I plan to do it in, and what I will check.

Step 0: do you need to move now

Spring AI 2.0 requires Spring Boot 4. So the real question is the Boot upgrade. Spring Boot 3.5 open source support ends on 30 June 2026. If you are on Boot 3.5 with Spring AI 1.x, you have to plan the move anyway. If the service is a prototype, you can wait a few weeks for the first patch release.

Step 1: upgrade Spring Boot first, without touching Spring AI code

Do the Boot 4 upgrade as its own change. Java 17 is the minimum for Boot 4; I use Java 25, the current LTS. Fix the Boot-level problems (Jackson 3, removed deprecated APIs, test changes) and get the tests green. Mixing the Boot and the Spring AI changes in one big commit makes it hard to know what broke.

In practice, you cannot run Spring AI 1.x on Boot 4. So “step 1” is a branch where you bump both, but fix the non-AI code first.

Step 2: bump the BOM

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.ai</groupId>
      <artifactId>spring-ai-bom</artifactId>
      <version>2.0.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

Then compile and read the errors. Most of them fall into the groups below.

Step 3: options are immutable, built with builders

In 2.0, chat options are created with builders and cannot be changed after they are built. copy() is removed. Use mutate():

// 1.x
OllamaChatOptions options = base.copy();
options.setTemperature(0.2);

// 2.0
OllamaChatOptions options = base.mutate()
        .temperature(0.2)
        .build();

ChatClient.options(...) now takes a builder, not a built object:

String answer = chatClient.prompt("Summarize the last 24 hours of sensor alerts")
        .options(OllamaChatOptions.builder().temperature(0.2))
        .call()
        .content();

If you kept options in a shared static field and changed them per request, that code was already unsafe. The compiler now forces the fix.

Step 4: property names lose the .options segment

The .options part of the property keys is removed. The 2.0 reference lists, for example, spring.ai.ollama.chat.model and spring.ai.ollama.embedding.model. For OpenAI embeddings:

# 1.x
spring.ai.openai.embedding.options.model=text-embedding-3-small
# 2.0
spring.ai.openai.embedding.model=text-embedding-3-small

For Ollama chat, spring.ai.ollama.chat.think-option becomes spring.ai.ollama.chat.think. The old keys still work for a transition period, but some removed keys are silently ignored. Silent is the part that worries me: a model setting you think you have is not applied. After the upgrade, log the effective options once at startup, or check them in a test.

Step 5: tool calling moves into ChatClient

This is the biggest behaviour change. In 1.x, each chat model ran its own tool-calling loop. In 2.0, ChatModel does not run the loop anymore. ChatClient registers a ToolCallingAdvisor automatically, and the advisor runs the loop.

What this means for your code:

  • If you call chatModel.call(prompt) directly and expect tools to run, they will not. Use ChatClient, or run the loop yourself with ToolCallingManager.
  • If you added ToolCallAdvisor yourself, remove it. The class is renamed to ToolCallingAdvisor, and it is registered automatically. Adding it again gives duplicates.
  • internalToolExecutionEnabled is removed from the options.
  • Advisor order changed. If you use a chat memory advisor together with tools, read the section on advisor order in the upgrade notes and test a multi-step conversation.

@Tool methods themselves work as before. The change is in who runs them.

Step 6: MCP

Spring AI 2.0 uses MCP Java SDK 2.0, which follows the 2025-11-25 MCP specification. The mcp-annotations project moved into Spring AI, so the packages change:

// 1.x (community project)
import org.springaicommunity.mcp.annotation.McpTool;
// 2.0
import org.springframework.ai.mcp.annotation.McpTool;

Streamable HTTP is now the default transport. The old SSE transport is deprecated. If you have clients that only speak SSE, keep them in mind before you switch the server. STDIO is still available for local tools.

Server-side input validation is on by default now. That is good, but a tool that accepted sloppy input before may now reject calls. Check your tool schemas against what your clients really send.

Step 7: provider modules

Some providers were reduced to one implementation. OpenAI is now SDK-only (OpenAI-compatible endpoints still work), Anthropic is SDK-only, Google is GenAI SDK only. Ollama, Mistral, DeepSeek and Amazon Bedrock stay. Some integrations moved to vendor-maintained repositories. If your pom.xml uses a starter that disappeared, look up its new home in the release notes before you write your own.

What to test

Unit tests with mocks will pass while the real behaviour changes. These are the tests that catch the real problems:

  1. One real tool call end to end. Ask a question that needs a tool, and assert the tool was called and the answer uses its result.
  2. Effective options. Assert that model, temperature and context size are what you configured.
  3. Structured output. If you map answers to Java records, test the mapping. Jackson 3 can behave differently on edge cases such as unknown fields or dates.
  4. Chat memory with tools. A two-turn conversation where turn two refers to a tool result from turn one.
  5. MCP client and server together. Start both and list tools.

Run these against a small local model with Ollama in CI if you can. It is slow, so keep it to a handful of tests.