Spring

Spring is a powerful set of tools designed for building web applications quickly and efficiently, allowing developers to create enterprise-level applications by using a simple and extensible way of making the code. Spring framework facilitates the use of Java or other languages to create the application and to be deployed on any sort of tiered server whether it be an HTTP server or an application server. Spring has been proven to add value in a wide range of environments, making a wide range of tasks easier for both smaller and larger teams. The framework provides different modules which can be used separately or together to create enterprise-level applications, bringing flexibility and simplicity to the development process. The official Spring site provides various resources and tools such as documentation, tutorials, training courses, and examples that help developers to get started and master the framework. The site also includes the latest release notes, updates, and a community section where developers can share ideas, get support, or contribute to the project.

Thread Of Notes

Applications often need to make typed decisions with predefined outcomes. While chat models can handle these tasks, converting their text replies into structured data adds complexity. Specialized decision models, like Jev, offer comparable accuracy with significantly lower latency and cost for classification and evaluation where input data is sufficient. Spring AI 2.1 introduces a DecisionModel API for these tasks, providing typed answers with probabilities directly. This API allows direct integration of model-based decisions into application control flow, eliminating the need for text generation and parsing.The article compares a local Ollama model with TypeSafe's Jev model across practical applications: guardrails and a judge. The DecisionModel API supports three question types: YesNoQuestion, ChoiceQuestion, and ScoreQuestion, each returning relevant data and probabilities. Probabilities are crucial for nuanced decision-making, enabling applications to distinguish between confident and uncertain responses for automated processing versus human review.The API is provider-independent, working with Ollama, OpenAI, and System One protocols. Guardrails, a natural application for yes/no questions, can screen messages for various hazards. Spring AI Decision Extensions provide a DecisionGuardrailAdvisor to evaluate user input and model output against predefined hazard "batteries". The advisor can pass, block, review, or support messages based on hazard scores and configurable thresholds.For instance, a message indicating self-harm can trigger a "SUPPORT" action, providing relevant resources. The interaction between probability and severity determines the action taken. Custom hazards can be defined, and advisor ordering is important, particularly for input screening to prevent blocked messages from being stored in session memory.
Spring AI 2.1 introduces tool call confirmation, allowing specific tools to require human approval before execution. This feature addresses the challenge of long wait times for approvals by pausing the automation loop and marking tools that need confirmation. Developers can mark tools using an annotation, properties for external tools, or a ToolCallConfirmationPolicy bean for argument-dependent rules. When a marked tool is requested, the system returns a ChatResponse indicating the calls awaiting decision, without executing them.The crucial aspect is that Spring AI does not maintain state during the pause; the prompt and the paused reply contain all necessary information for continuation. The new community project, Spring AI Session Extensions, complements this by managing the pause within the session log. It records the session's turn status, marking it as "parked" when awaiting confirmation and storing the question.To use Session Extensions, developers integrate a TurnAdvisor into their ChatClient configuration, which extends Spring AI's Session API. When a user requests a marked tool, the TurnAdvisor parks the session and logs the confirmation question. A separate process can then retrieve the session ID, access the pending question from the log, and present it for human approval.Upon receiving a decision (allow or deny), the approver's input is passed back to the system via the TurnStatusAdvisor. This advisor then executes allowed calls, records results in the session log, and allows the model to complete the turn. Denied calls are recorded with the approver's message, which the model can then use to inform the user.Key aspects include ensuring that confirmation questions are retrieved from secure storage, verifying approver permissions, and handling idempotency for tool executions. The demo illustrates this flow, showing how a mortgage payment collection tool pauses the process for approval, with the session status and question persisted in the log across JVM instances. This architecture ensures that sensitive operations are human-approved while maintaining a coherent conversation flow.
Spring AI 2.1.0 has been released, built on Spring Boot 4.2 with over 430 commits and 86 contributors. This release introduces the new, stateless Model Context Protocol (MCP) 2026-07-28, replacing previous versions. A significant addition is Decision Models, offering a structured API for typed yes/no, choice, and score decisions with three providers. The message model is richer, now supporting ordered message parts for reasoning, tool calls, and provider-specific blocks. An agent harness is forming with the Session API, session memory, tool call approvals, and guardrail refusals. Users can now provide their own embeddings, with eleven vector stores supporting custom computed vectors. The reference documentation has been reorganized for clarity, including a quickstart and tutorials. Security enhancements include fixes for 13 CVEs. Looking ahead, the Spring AI Agent project will incubate in December, focusing on composing and orchestrating agents. New MCP servers support asynchronous methods and runtime changes to tools, resources, and prompts. Modern MCP clients are lightweight and support per-request client-scoping. Decision models are integrated into RAG for document reranking and filtering, and in tool search for accurate tool selection. A community-maintained Spring AI Decision Extensions project offers ready-made building blocks based on the Decision Model API. The improved message model uses ordered MessagePart entries, enabling models to handle interleaved content. The OpenAI Responses API is now supported, providing better tool calling and reasoning with current OpenAI models. Tool call argument streaming allows UIs to display tool calls as they are being generated. Finally, generation finish reasons are categorized consistently across providers for easier handling.
Spring AI 2.1.0-RC2 is now available, featuring a new DecisionModel API for typed yes/no, choice, and score decisions. This API simplifies handling common application decisions by providing probabilities for predefined outcomes instead of free-form text. Implementations are available for OpenAI, Ollama, and System One, with full observability support.Key features include the integration of Decision Models into RAG post-processors like DecisionDocumentReranker and DecisionDocumentFilter, enhancing document processing. DecisionToolIndex is also introduced as a new tool search strategy, improving tool applicability judgment.The release also brings tool call argument delta streaming for several models, allowing UIs to display partial tool calls as they are generated. Support for user-provided embeddings has been extended to Neo4j, MongoDB Atlas, Typesense, MariaDB, and Chroma vector stores.The Spring AI MCP server now supports the 2026-07-28 "modern" protocol revision, offering a single POST endpoint for WebMVC and WebFlux transports. This modern protocol includes features like cacheable discovery, client capabilities, and server-initiated multi-round trip requests.Annotated tools, resources, and prompts are updated for the modern protocol with new attributes and callbacks, requiring potential migration for existing STREAMABLE servers. Smaller additions include SessionService enhancements and an upgrade to Anthropic Java SDK 3.x.Upgrade considerations involve changes to Anthropic API key handling, deprecation of temperature, topP, and topK in Anthropic SDK 3.x, and adjustments to TypesenseVectorStore initialization. Prompt token reporting for Anthropic and Bedrock Converse now includes cached tokens, potentially affecting existing token usage calculations.
Spring AI 2.1 introduces a significant change by replacing its previous message structure with an ordered list of message parts. This new data model is crucial for reasoning models that rely on returning specific blocks of thought and tool calls in their exact order. Previously, Spring AI messages lacked a defined structure for these opaque data types, leading to issues with ordering and loss of information, especially during streaming or when persisting memory.The MessagePart abstraction now serves as a universal way to represent text, reasoning blocks, tool calls, media, and even unknown data structures from various providers. This ensures that the order of content blocks, like reasoning followed by a tool call, is preserved. It also allows for opaque payloads, such as model signatures or encrypted reasoning, to be passed back to the model verbatim without interpretation, facilitating seamless transitions between different AI providers. Any content that Spring AI doesn't explicitly model is captured as an UnknownPart, ensuring it's replayed accurately.This update was essential for supporting OpenAI's newer Responses API, designed for reasoning models. This API returns an array of items like reasoning, function calls, and tool outputs, each with specific requirements for replaying. The MessagePart abstraction allows Spring AI to map these diverse items accurately, preserving their order and details for subsequent requests.The MessagePart system benefits various chat models by enabling them to replay crucial information like signed thinking blocks for Anthropic, thought signatures for Google GenAI, and reasoning content for OpenAI Chat Completions and others. This improves continuity, reduces errors, and maintains the full reasoning quality expected by these models. Session memory is also enhanced, allowing for the persistence of these ordered message parts across conversations. The overall gain is improved accuracy, reliability, and functionality when integrating with advanced AI models that leverage complex reasoning processes.
CdXz5zHNQW_tEWiQBMYFo.png
VectorStore.add() creates embeddings for text documents and saves them alongside the text. Spring AI 2.1 introduces upsert functionality, allowing applications to provide their own pre-generated embeddings for various media types like images, video, or audio. This feature bypasses the vector store's internal embedding model. A new similaritySearch overload accepts a query embedding, giving developers granular control over both data indexing and search queries. This is particularly useful for multimodal applications where text descriptions might not fully capture an item's characteristics shown in an image. For instance, a furniture catalog can store image embeddings alongside product details, enabling searches based on visual attributes. Similarly, video or audio content can be searched by embedding segments and matching them against text queries. Existing text embeddings, from any source, can also be managed efficiently through upsert, avoiding redundant re-embedding. Upsert ensures compatibility with the vector store's expected data formats for IDs, text, metadata, and vectors. When indexing product images, Spring AI's multimodal embedding models generate vectors that are paired with product metadata. This allows for a direct comparison between search text embeddings and stored image embeddings. Search queries are processed by embedding the search text with the same multimodal model. The similaritySearch method then uses this query embedding to find the most relevant results, filtering based on criteria like stock availability. It's crucial to use the same embedding model for both indexing and querying to ensure meaningful search results. Changing embedding models may necessitate re-generating stored embeddings, and tracking model versions in metadata is recommended. Upsert supports updating existing documents by replacing entries with matching IDs, preventing duplicate entries. While upsert calls are not transactional, retrying the entire list after resolving failures is advised. EmbeddedDocument validates vectors for completeness and finite values, and vector stores perform dimension checks before writing. Spring AI determines expected vector sizes from configuration or existing indexes, falling back to database-level checks if necessary. RedisVectorStore includes pre-write checks to prevent saving vectors of incorrect dimensions. As of Spring AI 2.1.0-RC1, PGvector, Redis, Elasticsearch, Qdrant, and OpenSearch support the new upsert and query embedding search capabilities. Applications can continue using add() for simple text embeddings, while the new features offer advanced control for complex multimodal scenarios.
The Spring AI team has announced the release of Spring AI 2.1.0-RC1 and 2.0.2, now available on Maven Central. Version 2.1.0-RC1 introduces several key features, including native message part handling across major chat models like OpenAI, Anthropic, and Google GenAI. This ensures the order and payload of reasoning, tool calls, and provider-specific blocks are preserved during conversations. A significant addition is the session memory, ported from the community Spring AI Session project, which manages long-running conversations as an append-only log of structured events with turn-aware compaction strategies. ChatMemory and related types are now deprecated in favor of this new session memory.Tool call confirmation is another new feature, allowing applications to approve or deny tool actions before they execute, enhancing user control over sensitive operations. This mechanism supports configurable policies for deciding which calls require confirmation. Furthermore, users can now search vector stores with their own pre-computed query embeddings, extending the functionality for custom embedding workflows. Several vector stores, including pgvector, Qdrant, Redis, Elasticsearch, and OpenSearch, implement this new search capability.Qxotic jinfer is now supported, providing a pure-JVM inference engine for ChatModel, EmbeddingModel, Text-to-Speech, and Speech-to-Text transcription. Audio capabilities have been expanded, with Google GenAI gaining text-to-speech and transcription models, and observability now covers speech, transcription, and image generation. Smaller enhancements include TokenTextSplitter supporting chunk overlap, PgVectorStore allowing custom column names, and Azure OpenAI accepting custom credentials.Upgrade notes highlight changes like BedrockChatOptions.requestParameters now being a Map and the deprecation of ChatMemory. Numerous fixes address issues across various providers and components, including Anthropic's answer generation, OpenAI's image MIME types, Google GenAI's tool call extraction, and Bedrock's tool-call arguments. Dependencies have also been updated, including Spring Boot, OpenAI Java SDK, and AWS SDK. Additionally, new versions of community integrations like the TypeSafe AI jev API client and Spring AI A2A have been released. Spring AI 2.0.2 has also been released, containing all fixes included in 2.1.0-RC1.
Spring AI's Modular RAG pipeline introduces JevDocumentFilter and JevDocumentReranker to enhance retrieval. These components process documents after retrieval, improving the quality of information presented to the language model. The system first rewrites and expands the user's question into multiple search queries using LLM calls. Then, retrieved documents are filtered by JevDocumentFilter, which assesses them based on relevance, potential prompt injection, and answer evidence. Following filtering, JevDocumentReranker prioritizes passages that directly answer the user's query. This modular approach addresses limitations of naive RAG, such as irrelevant results and noisy queries. The pipeline is configurable, allowing developers to swap out or tune individual components. Dependencies include Spring AI RAG, spring-ai-starter-typesafe, and typesafe-spring-ai. Ingestion involves reading PDFs, splitting text, and storing chunks in a vector store. The demo showcases how these post-retrieval steps significantly reduce irrelevant context. Jev components make individual LLM calls per passage, asking specific, calibrated questions. JevDocumentFilter uses four Noul questions with configurable thresholds to decide passage acceptance or rejection. JevDocumentReranker focuses on a single question to determine a passage's direct answer potential. The article emphasizes fixing the question before searching and fixing results before prompting. Filtering should precede reranking to optimize performance.
CdXz5zHNQW_fSjbrH5Ia5.png
CdXz5zHNQW_tT7W9JZdIl.png