A windswept bonsai on a floating island

Get to know Cadenya

We’re developers who love to build. We set out to create a yes-code platform that makes building agents feel like the best parts of building software.

Spring AI agents in production (2026)

Spring AI

By Cadenya

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 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 aloneSpring AI on TemporalSpring AI with DBOSSpring AI with RestateCadenya
Where the agent loop runsToolCallingAdvisor inside ChatClient, in your JVMA Workflow on your Workers. Model calls run as ActivitiesWorkflows and steps inside your Spring Boot appRestate services that run as Spring beansHosted. Your service creates an objective with one POST
Human approval of a tool callTurn off the automatic loop, or write a custom ToolAdvisor, and gate each callYour Workflow waits for a Signal or an Updatedbos.recv() in the workflow, dbos.send() from your endpointRestate.signal("approval", Boolean.class).await()Mark a tool as needing approval, then POST :approve or :deny with a memo
What a restart keepsThe messages in your chat memory repositoryEvent history, replayed by the WorkerWorkflow and step state in PostgresPersisted results of durable stepsThe objective’s durable event log
What you runYour app and the memory databaseA Temporal Service (four services, a persistence database, a Visibility store) and WorkersYour app and PostgreSQLOne Restate binary with a persistent volume, plus your appYour app, calling api.cadenya.com
Spring Boot artifactspring-ai-starter-model-* startersio.temporal:spring-ai 0.1.1 with temporal-spring-boot-starterdev.dbos:transact-spring-boot-starter 1.2.0dev.restate:sdk-spring-boot-starter 2.11.0Spring’s own RestClient and a @PostMapping webhook
LicenseApache-2.0Integration MIT, Java SDK Apache-2.0MITSDK MIT, server Business Source License 1.1SDKs are Apache-2.0

Choosing between Spring AI, LangChain4j and Embabel? The Java framework comparison 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:

VersionReleasedSpring Boot
2.1.0-RC2November 5, 20264.x
2.0.2October 23, 20264.0.x and 4.1.x
2.0.1August 21, 20264.0.x and 4.1.x
2.0.0June 12, 20264.0.x and 4.1.x
1.1.8June 12, 20263.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 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 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 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 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 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 explains. To create an account, sign up at app.cadenya.com/signup, then copy your API key from the API keys page at app.cadenya.com/account/apiKeys.

Grow wherever AI goes next.

Start shipping agents that are equipped to evolve.

A pine bonsai overlooking a mountain lake