---
title: "Spring AI agents in production (2026) — Cadenya"
url: "https://cadenya.com/other-content/spring-ai-agents-in-production"
description: "Spring AI 2.0 on Spring Boot 4 in production: tool calling with human approval, JDBC chat memory and compaction, MCP and Temporal."
---

A Spring AI agent in production is a `ChatClient` with `@Tool` methods, a chat memory repository such as `JdbcChatMemoryRepository`, and your own code to pause a tool call for human approval. Since the Spring AI 2.0 release (June 12, 2026, now at 2.0.2), Spring AI supports Spring Boot 4.0.x and 4.1.x, and the 1.1.x line pairs with Spring Boot 3.5.x.

So run Spring AI alone when conversations are short and every tool is safe to call. Add the Temporal Spring AI integration, DBOS or Restate when a model call has to survive a restart. And if you’d rather call an agent loop than run one, Cadenya is a hosted agent loop with approvals, conversation state, resume and model swap built in: your Spring Boot service calls its REST API and receives Standard Webhooks. A coding agent can set it up with no account, in a temporary workspace you claim later. [What it offers](#what-does-cadenya-add-to-a-spring-boot-agent) is at the end.

Every price and limit below comes from each vendor’s own pages, checked on November 11, 2026.

## Where the agent loop runs in a Spring Boot app

Here’s what each production setup asks of your Spring Boot app:

|  | Spring AI alone | Spring AI on Temporal | Spring AI with DBOS | Spring AI with Restate | Cadenya |
| --- | --- | --- | --- | --- | --- |
| Where the agent loop runs | ToolCallingAdvisor inside ChatClient, in your JVM | A Workflow on your Workers. Model calls run as Activities | Workflows and steps inside your Spring Boot app | Restate services that run as Spring beans | Hosted. Your service creates an objective with one POST |
| Human approval of a tool call | Turn off the automatic loop, or write a custom ToolAdvisor, and gate each call | Your Workflow waits for a Signal or an Update | dbos.recv() in the workflow, dbos.send() from your endpoint | Restate.signal("approval", Boolean.class).await() | Mark a tool as needing approval, then POST :approve or :deny with a memo |
| What a restart keeps | The messages in your chat memory repository | Event history, replayed by the Worker | Workflow and step state in Postgres | Persisted results of durable steps | The objective’s durable event log |
| What you run | Your app and the memory database | A Temporal Service (four services, a persistence database, a Visibility store) and Workers | Your app and PostgreSQL | One Restate binary with a persistent volume, plus your app | Your app, calling api.cadenya.com |
| Spring Boot artifact | spring-ai-starter-model-* starters | io.temporal:spring-ai 0.1.1 with temporal-spring-boot-starter | dev.dbos:transact-spring-boot-starter 1.2.0 | dev.restate:sdk-spring-boot-starter 2.11.0 | Spring’s own RestClient and a @PostMapping webhook |
| License | Apache-2.0 | Integration MIT, Java SDK Apache-2.0 | MIT | SDK MIT, server Business Source License 1.1 | SDKs are Apache-2.0 |

Choosing between Spring AI, LangChain4j and Embabel? The [Java framework comparison](/other-content/ai-agent-frameworks-in-java) covers that.

## Spring AI 2.0 release and Spring Boot 4 compatibility

The Spring AI 2.0 release post says it’s “designed to be used with Spring Boot 4.0 / 4.1 and Spring Framework 7.0.” The getting started guide puts it plainly: “Spring AI 2.0.x supports Spring Boot 4.0.x and 4.1.x.” For Spring Boot 3, the README pairs Spring AI 1.1.x with Spring Boot 3.5.x.

The latest releases, per the spring-projects/spring-ai GitHub releases and the `spring-ai-bom` page on Maven Central:

| Version | Released | Spring Boot |
| --- | --- | --- |
| 2.1.0-RC2 | November 5, 2026 | 4.x |
| 2.0.2 | October 23, 2026 | 4.0.x and 4.1.x |
| 2.0.1 | August 21, 2026 | 4.0.x and 4.1.x |
| 2.0.0 | June 12, 2026 | 4.0.x and 4.1.x |
| 1.1.8 | June 12, 2026 | 3.5.x |

Import the BOM and let it pick every module version:

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

**Check the Spring Boot support dates before you pick a line.** Per spring.io’s support table, open-source support for Spring Boot 3.3 ended on June 30, 2025, for 3.4 on December 31, 2025, and for 3.5 on June 30, 2026. Spring Boot 4.0 has OSS support until December 31, 2026, and 4.1 until July 31, 2027. The current release is 4.1.2 (October 22, 2026), and it “requires at least Java 17.”

## Spring AI ChatClient tool calling and human approval of tools

Tools are methods marked `@Tool`. In 2.0, `ChatClient` auto-registers a `ToolCallingAdvisor` that runs the loop: “The model decides which tools to call; ToolCallingManager executes them; the loop continues until the model produces a response without tool calls.” That design “replaces the per-ChatModel tool execution loops of Spring AI 1.x.”

The docs list “Gating tool execution on an external approval step” as a reason to own each iteration. You opt out of the automatic loop and drive it yourself:

```
ChatClientResponse response = chatClient.prompt()
    .user(question)
    .options(chatOptions)
    .advisors(AdvisorParams.toolCallingAdvisorAutoRegister(false))
    .call()
    .chatClientResponse();

Prompt prompt = new Prompt(List.of(new UserMessage(question)), chatOptions);

while (response.chatResponse() != null && response.chatResponse().hasToolCalls()) {
    // Your approval check goes here, before any tool runs
    ToolExecutionResult result = toolCallingManager.executeToolCalls(prompt, response.chatResponse());
    prompt = new Prompt(result.conversationHistory(), chatOptions);
    response = chatClient.prompt()
        .messages(result.conversationHistory())
        .options(chatOptions)
        .advisors(AdvisorParams.toolCallingAdvisorAutoRegister(false))
        .call()
        .chatClientResponse();
}
```

The tradeoff: driving the loop yourself “bypasses observability, advisor composition, and the single-ToolAdvisor invariant.” The other route is a custom `ToolAdvisor` that overrides hooks such as `doBeforeCall`, and the docs name an “Approval gate” (pause “before executing a destructive tool and wait for human confirmation”) as a common use.

**Either way, the pending call lives in your code.** Your app keeps the conversation and the pending call until the approver answers, then rebuilds the prompt. The approval screen is yours to build too. [Human-in-the-loop approvals for AI agents](/other-content/human-in-the-loop-approvals-for-ai-agents) covers the wider pattern.

## Spring AI chat memory: JdbcChatMemoryRepository and compaction

By default, Spring AI wires a `MessageWindowChatMemory` over an `InMemoryChatMemoryRepository`, and “The default window size is 20 messages.” In-memory history is gone after a restart, so production apps swap the repository.

`JdbcChatMemoryRepository` comes from the `spring-ai-starter-model-chat-memory-repository-jdbc` starter and supports PostgreSQL, MySQL and MariaDB, SQL Server, HSQLDB and Oracle Database. Schema creation defaults to `embedded`, so set `spring.ai.chat.memory.repository.jdbc.initialize-schema` to `always`, or to `never` when Flyway or Liquibase owns the table.

Two lines in the docs matter for agents:

1.  “JdbcChatMemoryRepository does not support tool call messages.” So the stored history keeps what the user and the model said, not which tools ran.
2.  “The ChatMemory.CONVERSATION\_ID parameter is required for all memory advisors.” There’s no default, so derive it per user and per conversation, as the docs show with `currentUser.getId() + ":" + httpSession.getId()`.

For compaction, the community project Spring AI Session (0.10.0, September 28, 2026, Apache-2.0) adds “turn-aware compaction” through a `SessionMemoryAdvisor`, with triggers such as `TurnCountTrigger(20)` and a JDBC store for PostgreSQL, MySQL, MariaDB and H2. It needs Spring AI 2.0.1 or later and Spring Boot 4.1.1 or later. [Agent memory and context windows](/other-content/agent-memory-and-context-windows) covers what belongs in the window.

## Spring AI Anthropic and OpenAI starters, multiple models and MCP

Each provider is a starter. Add `spring-ai-starter-model-anthropic` and set `spring.ai.anthropic.api-key`, and the chat model defaults to `claude-haiku-4-5`. Add `spring-ai-starter-model-openai` and set `spring.ai.openai.api-key`, and it defaults to `gpt-5-mini`. The 2.0 release keeps OpenAI, Anthropic, Amazon Bedrock, Google GenAI, Mistral AI, DeepSeek and Ollama in the core project.

“By default, Spring AI autoconfigures a single ChatClient.Builder bean,” and with several `ChatModel` beans Spring “cannot resolve the ChatModel dependency” without help. The docs build one `ChatClient` per provider through `ChatClientBuilderConfigurer`, mark one `@Primary`, and pick with `@Qualifier`. So adding a provider is a dependency change and a redeploy. [Switching model providers](/other-content/switching-model-providers-for-ai-agents) compares the ways to make that a setting.

MCP works both ways. `spring-ai-starter-mcp-client` connects to MCP servers, though “MCP providers are deliberately not auto-registered with the ChatClient,” so you inject `SyncMcpToolCallbackProvider` and pass it to `.tools()`. To expose your own beans, use `@McpTool` with `spring-ai-starter-mcp-server-webmvc`. Spring AI 2.0 “ships with MCP Java SDK 2.0.0,” and “Streamable HTTP is now the default, replacing the deprecated SSE transport.”

## Temporal Spring AI integration, DBOS and Restate for durable agents

The Temporal Spring AI integration “makes Spring AI agents durable: model calls run through Temporal Activities recorded in Event history.” It ships as `io.temporal:spring-ai` (0.1.1 on Maven Central, October 16, 2026), next to `temporal-spring-boot-starter`, and needs Java 17, Spring AI 2.0.1, Spring Boot 4.0.8 (4.1.1 is also tested) and Temporal Java SDK 1.40.0 or later.

Inside a Workflow, you wrap `ActivityChatModel` in a `TemporalChatClient` and register tools as Activity stubs. The sample keeps chat memory in an `InMemoryChatMemoryRepository` that “gets rebuilt on replay,” keyed by the Workflow ID. Moving from the older `io.temporal:temporal-spring-ai` package? Finish running executions first, since their histories are “incompatible” with the new module. [Temporal for AI agents](/other-content/temporal-for-ai-agents) covers Signals, Worker Versioning and Temporal Cloud pricing.

DBOS and Restate keep the loop in your Spring Boot app:

1.  **DBOS.** `dev.dbos:transact-spring-boot-starter` 1.2.0 (October 1, 2026, MIT) runs workflows inside the app, and “DBOS requires a PostgreSQL database.” An approval is a `dbos.recv()` in the workflow and a `dbos.send()` from your controller.
2.  **Restate.** `dev.restate:sdk-spring-boot-starter` 2.11.0 (October 28, 2026) turns services into Spring beans. Restate’s docs list signals for “agent steering, and human approvals,” and they ask for SDK 2.9.3 or later “with Spring AI 2.x.”

## What does Cadenya add to a Spring Boot agent?

Spring AI runs the loop inside your JVM, and the pending approvals and the state are still yours to run. **Cadenya is the agent loop itself, hosted, and a Spring Boot service drives it over HTTP.** Here’s what that covers:

1.  **One POST starts the agent.** Your service calls `POST /v1/workspaces/{workspaceId}/objectives` on `api.cadenya.com` with a bearer API key. An OpenAPI spec describes the REST API, so `RestClient` or a generated client both work.
2.  **Approvals as a tool setting.** Mark a tool as needing approval, and Cadenya “parks the Agent loop until it receives approval or a denial with optional steering.” Several tools can wait at once. Your service answers with `:approve` or `:deny`, and a denial carries a memo the agent reads.
3.  **Standard Webhooks into a controller.** Set one URL on the agent, and Cadenya sends a signed POST for each message, tool call, approval and error. An `objective_event.tool_approval_requested` delivery carries the objective ID and `toolCallId`, so your controller can open the approval right away.
4.  **Conversation state and resume.** Every objective carries a durable event log of its agent loop, tool calls included. Stream it over server-sent events and resume with the last event ID, or send a Continue message to a waiting objective.
5.  **Compaction on the variation.** The variation holds a compaction config, and the Compact an objective endpoint compacts on demand, so long conversations need no extra library.
6.  **Model swap with no deploy.** The model is a setting on an agent variation, not a bean. Connect your own AI provider keys, pay the provider directly, and let weighted variations favor whichever variation scores well.
7.  **Tools from your existing APIs.** A tool set can come from an OpenAPI 3.0 spec, an MCP server, HTTP endpoints you define, or Bare tools your app answers. If your Spring Boot app already publishes an OpenAPI spec, point a tool set at its URL, and Cadenya checks it for changes each hour.
8.  **A price in one line.** Free for 1,000 loops a month, Growth at $49 a month for 50,000, then $0.0015 a loop. A loop is one LLM request made during an objective.

Here’s the Spring side, adapted from the REST reference and the Standard Webhooks headers in the webhooks guide:

```
@Service
class AgentClient {
    private final RestClient http = RestClient.builder()
        .baseUrl("https://api.cadenya.com/v1/workspaces/" + System.getenv("CADENYA_WORKSPACE_ID"))
        .defaultHeader("Authorization", "Bearer " + System.getenv("CADENYA_API_KEY"))
        .build();

    Map<?, ?> start(String orderId, String question) {
        return http.post().uri("/objectives")
            .contentType(MediaType.APPLICATION_JSON)
            .body(Map.of(
                "agentId", "external_id:support-agent",
                "metadata", Map.of("externalId", "order-" + orderId),
                "firstUserMessageData", Map.of("question", question)))
            .retrieve()
            .body(Map.class);
    }

    void approve(String objectiveId, String toolCallId) {
        http.post().uri("/objectives/{o}/tool_calls/{t}:approve", objectiveId, toolCallId)
            .retrieve().toBodilessEntity();
    }

    void deny(String objectiveId, String toolCallId, String memo) {
        http.post().uri("/objectives/{o}/tool_calls/{t}:deny", objectiveId, toolCallId)
            .contentType(MediaType.APPLICATION_JSON)
            .body(Map.of("memo", memo))
            .retrieve().toBodilessEntity();
    }
}

@RestController
class AgentWebhook {
    private final byte[] key = Base64.getDecoder().decode(
        System.getenv("CADENYA_WEBHOOK_SECRET").substring("whsec_".length()));

    @PostMapping("/webhooks/cadenya")
    ResponseEntity<Void> receive(@RequestHeader("webhook-id") String id,
                                 @RequestHeader("webhook-timestamp") String ts,
                                 @RequestHeader("webhook-signature") String signatures,
                                 @RequestBody byte[] body) throws Exception {
        if (Math.abs(Instant.now().getEpochSecond() - Long.parseLong(ts)) > 300) {
            return ResponseEntity.status(401).build();
        }
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(new SecretKeySpec(key, "HmacSHA256"));
        mac.update((id + "." + ts + ".").getBytes(StandardCharsets.UTF_8));
        byte[] expected = ("v1," + Base64.getEncoder().encodeToString(mac.doFinal(body)))
            .getBytes(StandardCharsets.UTF_8);
        boolean valid = Arrays.stream(signatures.split(" "))
            .anyMatch(s -> MessageDigest.isEqual(s.getBytes(StandardCharsets.UTF_8), expected));
        if (!valid) {
            return ResponseEntity.status(401).build();
        }
        // Store webhook-id with a unique constraint, then route on the event type
        return ResponseEntity.ok().build();
    }
}
```

[Webhooks](/docs/guides/the-basics/webhooks) walks through the envelope, event types and approval flow, and the free plan needs no card.

No account yet? A coding agent can create a temporary workspace with `cadenya workspaces create --temporary`, run its first objectives there, and hand you a link to claim it, as [auth.md](https://cadenya.com/auth.md) explains. To create an account, sign up at [app.cadenya.com/signup](https://app.cadenya.com/signup?utm_source=cadenya.com&utm_medium=article&utm_campaign=spring-ai-agents-in-production), then copy your API key from the API keys page at `app.cadenya.com/account/apiKeys`.