跳到主要内容

Building a Production-Ready Agent with Spring AI

· 阅读需 7 分钟

An agent that works in a demo can still fail in production. A tool may time out, the model may return an invalid argument, or a retry may repeat an operation that has already changed data. Production readiness comes from making these boundaries explicit.

This article builds on the agent concepts and task execution pattern already covered on this site. The goal is a bounded assistant that can look up an order and, when allowed, request a cancellation. The same principles apply to other Spring AI agents.

Migrating from Spring AI 1.x to 2.0

· 阅读需 5 分钟

Spring AI 2.0 went GA in June 2026. It's a much bigger jump than a typical minor version bump: the internal tool-calling loop is gone, several provider modules were rewritten on top of vendor SDKs, and the baseline platform itself changed. Here are the changes that are most likely to break an existing 1.x application, and how to deal with them.

Use rustfs with Langfuse

· 阅读需 1 分钟

After MinIO stops its active development, I'm looking for its alternatives. rustfs is my choice.

OpenAI br encoding issue with Spring AI

· 阅读需 3 分钟

If you encountered JSON error when using Spring AI to interact with OpenAI, remove br from Accept-Encoding header.

This can be done by configuring RestClient and WebClient used by OpenAiApi, see the code below. Accept-Encoding header is set to gzip, deflate.

Update Accept-Encoding header
OpenAiApi.builder()
.apiKey("<api-key>")
.restClientBuilder(RestClient.builder().defaultHeader(HttpHeaders.ACCEPT_ENCODING, "gzip, deflate"))
.webClientBuilder(WebClient.builder().defaultHeader(HttpHeaders.ACCEPT_ENCODING, "gzip, deflate"))
.build()

Use OpenAI GPT-5

· 阅读需 1 分钟

OpenAI GPT-5 is a reasoning model, so it doesn't support the parameter temperature. GPT-5 Chat is a chat model. To replace GPT 4o in an app, you should use GPT-5 Chat.

Giving up Chroma, Embracing Pgvector

· 阅读需 2 分钟

For my local development of AI applications using Spring AI, I have been used Chroma for a long time. It used to be a very smooth experience. I just installed Chroma using pip and started it using chroma run. In Spring AI, I simply use the Spring Boot starter.

Spring AI Client for OpenAI with Official SDK

· 阅读需 2 分钟

I'm working on a project which is still using Spring 5. When I was trying to use Spring AI in this project, it turned out that the default OpenAIChatModel couldn't be used. This is because OpenAIChatModel uses RestClient, which is only available in Spring 6.