Spring AI 2.1: Human-in-the-Loop Tool Calls, Ordered Message Parts & DecisionModel
Spring AI 2.1 introduces framework-level tool call confirmation for human-in-the-loop agent safety, ordered Message Parts to preserve model reasoning order across providers, OpenAI Responses API support for combined tool use and reasoning, and a new DecisionModel interface for probabilistic classification tasks.
Reading font

Core Changes: Tool Call Confirmation
Spring AI 2.1 addresses a critical gap in enterprise agent deployment: the lack of a framework-level gate for high-risk tool invocations. Previously, developers had to wrap ToolCallingManager to intercept tool calls, pause execution, await human decisions, and resume — a process fraught with state management challenges across service restarts and multi-instance deployments. Most teams simply disabled risky tools or relied on prompt instructions.
2.1 introduces Tool Call Confirmation as a first-class capability. Annotate a tool method with
@Tool(description = "Book a flight", requiresConfirmation = true). When the model attempts to call this tool, the entire tool-calling loop pauses before any execution, returning a response that lists all pending confirmations. The application collects a ToolCallDecision (allow or deny with a message) for each call and resumes via
ToolCallingManager.executeToolCalls(prompt, reply, decisions). Denied calls return the denial message to the model instead of executing.
Key design: The pause is a stateless response return; resumption is a normal request. No server-side state is retained during the wait, so service restarts and multi-instance deployments recover seamlessly as long as the conversation history is persisted. Confirmation policy is governed by ToolCallConfirmationPolicy — default reads tool metadata, forTools(...) targets tools you don't own (e.g., MCP tools), and lambdas can inspect arguments (e.g., confirm only transfers above a threshold).
Note: Cross-agent human-in-the-loop workflows are part of the Spring AI Agent roadmap, not the 2.1 core.
Message Parts: Preserving Reasoning Order
Previous Problem: Flat Message Structure
Before 2.1, AssistantMessage held a single text field plus separate lists for toolCalls and media. This could not represent the interleaved order of reasoning, tool calls, and text that modern models (Anthropic Claude, Google Gemini, DeepSeek reasoning models) actually produce. For example, Anthropic requires thinking blocks to be returned verbatim in their original sequence; reordering or dropping them yields HTTP 400 errors. Spring AI previously rebuilt tool turns as "text → thinking → tool", ignoring the model's actual order.
2.1 Solution: Ordered MessagePart List
Messages now contain an ordered list of MessagePart objects, each a discrete segment: TextPart — plain text ReasoningPart — reasoning content, may carry an OpaquePayload (e.g., Anthropic's thinking signature) ToolCallPart — tool invocation ToolResultPart — tool result MediaPart — images, audio, PDFs UnknownPart — preserves raw JSON for unrecognized blocks, preventing silent loss
Parts maintain the model's original output order, enabling faithful round-trips. Convenience methods getText(), getMedia(), getToolCalls(), getReasoning() are views over the parts list; legacy constructors and builders remain.
UserMessage question = UserMessage.builder()
.part(TextPart.of("What differs between these two charts?"))
.part(MediaPart.of(firstChart))
.part(MediaPart.of(secondChart))
.build();
AssistantMessage answer = chatModel.call(new Prompt(question)).getResult().getOutput();
for (ReasoningPart reasoning : answer.getReasoning()) {
System.out.println("Reasoning: " + reasoning.text());
}
System.out.println(answer.getText());Version difference: Message Parts debuted in 2.1.0-M1 but only OpenAiResponsesChatModel natively produced/consumed them. Other ChatModel implementations (Ollama, Anthropic, OpenAI Chat Completions) were refactored to use Parts in RC1. Full Parts replay for non-Responses models requires RC1 or later.
Underlying Principle: Provider-Specific Replay Requirements
Different models impose distinct replay constraints: Anthropic demands thinking blocks with signatures in order; Google GenAI requires each thought signature to return to its original Part, else Gemini 3+ function calling returns 400; OpenAI Responses requires reasoning items with encrypted encrypted_content. The Parts abstraction normalizes these differences at the framework layer, eliminating per-model replay logic.
OpenAI Responses API
Why a New Endpoint
Spring AI originally used OpenAI's Chat Completions endpoint ( /v1/chat/completions). From GPT-5.4 onward, that endpoint rejects the combination of tool calls with non- none reasoning effort (e.g., high or medium). Agents needing deep reasoning before tool use were blocked.
The Responses API ( /v1/responses) natively supports tool calls combined with reasoning, and preserves reasoning via encrypted reasoning items across tool turns.
Switching
Set one property: spring.ai.openai.chat.api=responses All other connection settings ( api-key, base-url, model) remain unchanged; OpenAiResponsesChatModel auto-configures.
Key design: OpenAiResponsesChatModel is stateless — every call sends the full prompt. ChatMemory, Advisors, and RAG work identically to OpenAiChatModel; no server-side conversation state is used.
Note: The two OpenAI endpoints are mutually exclusive by default. Simultaneous use (e.g., Chat Completions for cheap classification, Responses for agents) requires explicit builder declaration of the second.
DecisionModel: Probabilistic Classification
Problem
Many scenarios need a judgment — sentiment, security risk, relevance — not generated text. Using a ChatModel works but is costly and slow; ChatModels excel at generation, not classification.
2.1 Solution: DecisionModel Interface
Introduced in RC2, DecisionModel performs "judgments with calibrated probabilities". It supports three answer types: Choice (pick from options), Noul (yes/no probability), Score (graded scale).
// Decide if a ticket needs escalation
DecisionResponse response = decisionModel.evaluate(
"Customer says 'I was double-charged, please resolve urgently'",
DecisionRequest.builder()
.choice("category", "Ticket category", "billing", "technical", "other")
.noul("is_urgent", "Is urgent")
.build()
);
// Act on probability
if (response.getNoul("is_urgent").isYes(0.9)) {
escalateToHuman();
}Three implementations:
OpenAI: OpenAiDecisionModel backed by OpenAI Decisions API, auto-configured under spring.ai.openai.decision.
Ollama: OllamaDecisionModel defaults to d1-omni:600m, runs locally, no API key.
System One: SystemOneDecisionModel via TypeSafe Java SDK, compatible with Jev, Laya, etc. Not auto-configured ; requires manual TypeSafeClient creation.
Underlying Principle
ChatModel returns text requiring parsing; DecisionModel returns calibrated probabilities. Code can directly use isYes(0.9) thresholds to trigger actions. Caution: DecisionModel is an ML model, not a rules engine. Outputs are non-deterministic; probabilities are not absolute. Thresholds must be set by the developer, accepting some error rate. Official docs discuss threshold thinking and error handling.
Other Notable Changes
Streaming Tool Call Parameters
Model streams tool arguments incrementally. 2.1 exposes these partial ToolCallPart objects (marked with a partial flag) so UIs can display arguments as they are generated. Partial parts are ignored by getToolCalls() and ToolCallingManager; the complete call arrives later at the same index.
Extended Vector Store Custom Embedding Support
M1 added VectorStore.upsert() for pre-computed vectors; RC1 added similaritySearch(float[], SearchRequest) for custom query vectors. RC2 extends both to Neo4j, MongoDB Atlas, Typesense, MariaDB, Chroma, and more.
Session API Evolution
ChatMemoryand related types are deprecated in 2.1; migration to Session API is required. Session API introduces Turn (one UserMessage plus subsequent events), composable compaction triggers and strategies (sliding window, turn window, token count, recursive summarization). SessionMemoryAdvisor plugs transparently into ChatClient; conversation_search tool enables keyword retrieval over compacted history. Note: Official Session API docs lack a multi-agent chapter; cross-agent confirmation flows remain in Spring AI Agent planning.
Pros and Cons
Pros
Tool call confirmation — framework-level pause/resume for high-risk ops; survives restarts and multi-instance deployments.
Message Parts — ordered parts preserve interleaved reasoning, tool calls, text; satisfies Anthropic, Gemini, DeepSeek replay needs.
OpenAI Responses API — correct endpoint for agents needing tool use + reasoning effort.
DecisionModel — probability-first classification; decisions via isYes(threshold) without text parsing.
Streaming tool parameters — UI shows arguments as model writes them.
Cons
Migration cost — ChatMemory deprecated; custom message handling must adapt to Parts.
Parts support version gap — M1 only for OpenAI Responses; other models need RC1+ for full Parts.
DecisionModel extra config — System One implementation requires manual TypeSafeClient.
Multi-agent human-in-the-loop not yet — cross-agent confirmation flows slated for Spring AI Agent.
Applicability
Enterprise agents with high-risk tools needing human confirmation — strongly recommended; Tool Call Confirmation is essential.
Full model reasoning replay required — strongly recommended; Message Parts preserve order and signatures.
Using OpenAI flagship models for agents — strongly recommended; Responses API is the correct endpoint.
Ticket classification, risk scoring, relevance grading — strongly recommended; DecisionModel fits better than ChatModel.
Streaming tool argument display — recommended; incremental parameter exposure.
Heavy ChatMemory users — evaluate; migration to Session API needed.
Multi-agent human handoff — evaluate; await Spring AI Agent.
Conclusion
Spring AI 2.1 is worth upgrading if your agents "do real things". It shifts from "how to call models" to "how to call them safely, correctly, controllably". Tool Call Confirmation makes human gating a framework primitive; Message Parts stop reasoning loss; Responses API unlocks reasoning+tools on OpenAI; DecisionModel gives classification a proper tool. Together they move Spring AI from an AI integration layer toward an agent runtime. Migration hurdles (ChatMemory deprecation, Parts version split, DecisionModel config, multi-agent gaps) are real but trade for production-grade safety.
Reference: Spring AI 2.1.0-M1 announcement — https://spring.io/blog/2026/09/25/spring-ai-2-1-0-M1-available-now
For questions about attribution, corrections or content rights, please contactand we will review it promptly.