Spring AI 2.0 in Practice: Core Agent Development Capabilities and Code Generation Assistant Project

Spring AI 2.0 adds native Agent capabilities to Java, enabling autonomous reasoning and tool-calling AI assistants.
Spring AI 2.0's key innovation is elevating Agents to first-class framework citizens, adding ReAct-pattern autonomous reasoning, tool invocation, and iterative loops. This tutorial walks through building a Claude Code-style code generation assistant, covering ChatClient, Streaming, Memory, Tools, MCP, planning, and long-term memory—giving Java developers a practical path into AI Agent development.
Spring AI 2.0 Core Updates Explained
As the most closely watched AI development framework in the Java ecosystem, Spring AI has sparked extensive discussion among developers since releasing version 2.0. Bilibili content creator Xu Shulai offered a sharp insight in his tutorial series: Over 90% of Spring AI 2.0's content remains consistent with 1.0—the real innovation lies in the newly added Agent ecosystem layer.
In other words, if you're already familiar with Spring AI 1.0's foundational capabilities like ChatClient, Embedding, ChatModel, and RAG, the learning curve for migrating to 2.0 is minimal. What truly demands attention is the Agent foundation capabilities that 2.0 brings to the table.
In the 1.0 era, Spring AI was essentially just a "large model caller"—invoking LLMs and combining them with Tools to build a chatbot. To implement a true Agent (autonomous planning, independent reasoning, iterative loops), developers had to rely on Alibaba's open-source framework Spring AI Alibaba Agent Framework. Spring AI Alibaba is Alibaba's AI development framework built on top of Spring AI, and its Agent Framework filled the gap when Spring AI 1.0 lacked Agent capabilities, providing advanced features like Graph orchestration, multi-Agent collaboration, and state management. With Spring AI 2.0 natively introducing Agent support, the relationship between the two has become nuanced: basic Agent loop capabilities can be handled directly with Spring AI 2.0, while complex multi-Agent orchestration and directed graph workflows remain areas where Spring AI Alibaba holds an advantage.

The Leap from Chatbot to Autonomous Agent
The most critical upgrade in version 2.0 is giving the framework itself the most fundamental Agent capability: autonomous reasoning, Tool invocation, action execution, followed by iterative loops until the task is complete.
The technical foundation for this capability is the ReAct (Reasoning + Acting) pattern from the AI field. Unlike traditional single-turn conversations, ReAct requires the system to first reason about the current state, decide on the next action, execute it, observe the results, and then enter the next reasoning cycle. This loop continues until the task objective is achieved. This paradigm was first proposed by Google DeepMind in a 2022 paper, and was subsequently adopted widely by frameworks like LangChain and AutoGPT, becoming a core architectural pattern in AI application development. Spring AI 2.0 officially embeds this pattern into the framework, enabling Java developers to build Agents in a declarative manner.
This may seem simple, but it represents a watershed moment—the crossing from "Q&A-style" interaction to "task-style" execution. Traditional chatbots operate on a question-and-answer basis, while Agents can revolve around an objective, repeatedly calling tools, evaluating results, and adjusting strategies until the problem is truly solved.

According to Xu Shulai's analysis, combined with the Agent toolkit provided by the Spring AI community, developers can accomplish complete Agent development. This toolkit has a particularly interesting characteristic—it directly reverse-engineers Claude Code's implementation approach. Claude Code is Anthropic's command-line AI programming assistant capable of reading project code, understanding context, and executing file operations and Shell commands. "Reverse-engineering Claude Code" refers to analyzing Claude Code's behavioral patterns (such as file read/write tools, code search tools, command execution tools, etc.) and re-implementing a similar toolchain using Spring AI's Agent framework. The advantage of this approach is that Claude Code has already validated which tool combinations are most effective for code generation tasks, allowing developers to directly borrow its design philosophy rather than exploring the optimal tool set from scratch. This means developing a code generation assistant based on it is extremely low-cost while enabling rapid mastery of Spring AI 2.0 and Agent core toolchains through hands-on practice.
Hands-on Project: Building a Code Generation Assistant with Spring AI 2.0
The tutorial culminates in a practical project: developing a Claude Code-like code generation assistant using Spring AI 2.0 + the Spring AI Agent toolkit. The choice of this project is pragmatic—it covers Spring AI 2.0's core features while leveraging existing toolkits to lower the development barrier.
The course follows a progressive technical path covering these key areas:
Foundation Layer
- LLM Conversation: The most basic ChatClient invocation. Spring AI abstracts away differences between various LLM providers (OpenAI, Anthropic, Alibaba Tongyi, etc.) through a unified API, allowing developers to switch underlying models by simply changing configuration
- Streaming Output: A key technology for enhancing interaction experience. Based on Server-Sent Events (SSE) or WebFlux reactive streams, it enables token-level real-time output, preventing users from waiting for complete response generation
- Memory: Giving conversations contextual continuity. Spring AI provides multiple Memory implementations, including window-based short-term memory (retaining the most recent N conversation turns) and summary-based compressed memory, ensuring semantic coherence within token limits
- Tools and MCP: Tool invocation and Model Context Protocol integration. MCP is an open protocol standard launched by Anthropic in late 2024, aimed at unifying the interaction between LLMs and external tools/data sources. Before MCP, each AI framework had its own tool invocation specification, leading to tool ecosystem fragmentation. MCP defines a standardized communication format, similar to how HTTP unified web communication. Spring AI 2.0's native MCP support means developers can directly reuse the vast number of existing MCP tool servers in the community

Among these, RAG (Retrieval-Augmented Generation) is the core technology for addressing LLM knowledge currency and hallucination issues. Its workflow involves: slicing enterprise private documents, converting them to vectors via Embedding models, and storing them in vector databases; when users ask questions, relevant document fragments are first retrieved, then injected as context into the Prompt, and finally the LLM generates answers based on real data. Spring AI has provided complete RAG Pipeline support since 1.0, including abstractions for document loading, chunking strategies, vector storage, and retrievers.
Agent Advanced Layer
Building on the Agent toolkit's capabilities, the tutorial also covers several advanced features:
- Ask User Question: The LLM proactively asks users questions to fill information gaps in prompts—this is a crucial mechanism for Agent-user collaboration. In traditional dialogue systems, models tend to "guess" or hallucinate when information is insufficient, while the Ask User Question mechanism allows Agents to identify their own information gaps and proactively seek clarification, significantly improving task completion accuracy
- Skills: Skill encapsulation that gives Agents reusable capability units. Similar to modularization in software engineering, Skills package domain-specific Prompt templates, tool combinations, and execution logic into independent units that can be shared and reused across different Agents
- Planning: Agents autonomously orchestrating execution paths. When facing complex tasks, the Agent first decomposes objectives into multiple subtasks, determines execution order and dependencies, then executes step by step. This mirrors how humans approach complex projects—first creating a plan, then progressing incrementally
- Long-term Memory: Knowledge retention across sessions. Unlike short-term memory within a single conversation, long-term memory persistently stores user preferences, project context, historical decisions, and other information, enabling Agents to maintain prior cognition in new sessions and provide personalized, continuous service
These features combined are what truly constitute a usable Agent application.
Recommended Learning Path for Spring AI 2.0
For developers wanting to dive deep into Spring AI, here's a clear roadmap:
If you want to dig into Spring AI's underlying details, including ChatClient, Embedding, ChatModel, RAG, and source code—these topics were already comprehensively covered in the 1.0 tutorial series and can be studied directly, since 2.0 hasn't fundamentally changed this layer.

If your goal is Agent development, then 2.0 is where you should focus. Pay particular attention to:
- Spring AI 2.0's native Agent iterative loop capability
- The Spring AI community's Agent toolkit (reverse-engineering Claude Code)
- The relationship and trade-offs with Alibaba's Spring AI Alibaba Agent Framework
Summary: What Spring AI 2.0 Means for Java Developers
The significance of Spring AI 2.0 lies not in restructuring foundational capabilities, but in officially making Agents a first-class citizen of the framework. This marks official-level support for AI Agent development in the Java ecosystem—developers no longer need to rely entirely on third-party frameworks to implement autonomous reasoning and tool-calling intelligent agents.
From an industry trend perspective, 2024-2025 represents a critical inflection point as AI applications transition from "conversational" to "agentic." In the Python ecosystem, Agent frameworks like LangChain, CrewAI, and AutoGen have already matured, while the Java ecosystem has long lacked equivalent solutions. The release of Spring AI 2.0 means that the Java ecosystem—which dominates enterprise development—has finally filled this critical piece of the puzzle, allowing Java developers to complete their technical transition from traditional backend to AI Agents within the familiar Spring ecosystem.
For Java backend developers, the combination of Spring AI 2.0 + Agent toolkit + Claude Code reverse implementation provides a path with a low learning barrier and high practical value. Whether building code assistants, internal enterprise Agents, or exploring converged applications of RAG + Tools + MCP, this technology stack is well worth deep study.
Key Takeaways
Related articles

iPhone Duo vs Z Fold 8: Which Foldable Nails Cover Screen and Form Factor Experience Better?
Based on a YouTube comparison, we analyze the iPhone Duo vs Samsung Z Fold 8 in cover screen ratio, one-handed grip, pocketability, app adaptation, multi-posture use, and keyboard input.

Why Tech Media Always Gets Accused of "Shilling"? The Verge Editor-in-Chief Responds to Bias Allegations
After The Verge's Duo review drew accusations of bias, Editor-in-Chief Nilay Patel responds: no paid reviews, no brand deals, editorial independent of sales, and details the ethics policy.

Claude Code 3x Speedup: Thanks to 1997's GZip Technology
Claude Code achieves 3x faster local sessions and 2.8x faster cloud sessions by enabling GZip compression. This article analyzes how this classic technology optimizes message transmission efficiency in AI coding tools and what it means for developers.