Spring AI 2.0 in Practice: Building an Enterprise-Grade Code Assistant Agent from Scratch

Build a Claude Code-style code assistant with Spring AI 2.0's new Agent capabilities and Agent Utils toolkit.
Spring AI 2.0's core upgrade is its new Agent foundation layer, enabling autonomous reasoning, tool calling, and iterative execution via the ReAct paradigm. This article walks through building an enterprise-grade code assistant by leveraging the community's Agent Utils toolkit — reverse-engineered from Claude Code — covering ChatClient basics, streaming output, memory, MCP integration, proactive questioning, skills, task planning, and long-term memory.
What Spring AI 2.0 Actually Updated
Many developers shared a common question after the release of Spring AI 2.0: what substantial changes did this major version upgrade actually bring? Based on the tutorial series by Bilibili content creator Xu Shu, the answer is quite focused — the most critical update in Spring AI 2.0 is the completion of the Agent foundation layer.
In the Spring AI 1.0 era, the framework could essentially only call large models, combine Tools and Memory to build a chatbot. It lacked true Agent capabilities: autonomous reasoning, autonomous decision-making, and iterative looping until tasks are completed. These capabilities previously required third-party open-source frameworks like Alibaba's Spring AI Alibaba (Agent Framework) to fill the gap.
Spring AI Alibaba is an open-source AI application development framework built on top of Spring AI by Alibaba, positioned as an upper-layer extension of the Spring AI ecosystem. It primarily addresses the shortcomings of the native Spring AI framework in complex Agent scenarios, providing a Graph-based Workflow orchestration engine, multi-Agent collaboration mechanisms, enhanced DocumentReader, and deep integration with mainstream Chinese LLMs (Qwen, ERNIE Bot, etc.). Its Workflow orchestration capability allows developers to define Agent execution paths as Directed Acyclic Graphs (DAGs), supporting conditional branching, parallel execution, and state transitions — suitable for AI-driven transformation of enterprise-level complex business processes.

It's worth emphasizing that over 90% of Spring AI 2.0's content is actually carried over from 1.0. Core capabilities like ChatClient, ChatModel, various LLM integrations, and Prompt formatting remain fundamentally unchanged from 1.0. In Spring AI's architecture, ChatModel is the low-level abstract interface responsible for defining unified interaction contracts with different model providers (OpenAI, Anthropic, Ollama, etc.), including message sending, parameter configuration, and response parsing. ChatClient, on the other hand, is the high-level fluent API designed for developers, using the Builder pattern to provide chain calls, default system prompt configuration, output format conversion, and other convenience features. This layered design follows Spring's longstanding philosophy: low-level interfaces ensure extensibility and replaceability, while high-level clients deliver developer experience and productivity.
The real increment lies in the newly added Agent ecosystem layer. Therefore, for developers who want to dig deep into the underlying source code and details, knowledge from 1.0 remains entirely applicable.
Agent Capabilities: From Chatbot to Autonomous Intelligent Agent
The fundamental difference between an Agent and a traditional chatbot is that it possesses a complete execution loop: autonomous reasoning → calling Tools to take action → observing results → iterative looping → until the task is completed. This is exactly the core of the so-called ReAct (Reasoning + Acting) paradigm.
ReAct is a large language model reasoning framework jointly proposed by Princeton University and Google Brain in 2022. Its core idea is to have the model alternate between reasoning (Thought) and acting (Action) while executing tasks, observing environment feedback (Observation) after each action. Compared to pure Chain-of-Thought reasoning, ReAct solves the problems of model "hallucination" and outdated knowledge by introducing external tool interactions. In practical implementations, a ReAct Agent typically maintains a loop: the model first generates a reasoning step to decide what to do next, then calls tools to obtain real data, and finally feeds the observation results back to the model, which determines whether further iteration is needed. This paradigm has become the foundational architecture of mainstream Agent frameworks (such as LangChain, AutoGPT, etc.).

Spring AI 2.0 implements this basic set of Agent capabilities at the framework level. This means developers no longer need to introduce heavy external frameworks just to build an intelligent agent capable of autonomous task execution. Of course, for more complex autonomous planning, autonomous path orchestration (Workflow orchestration), and multi-Agent collaboration, extension frameworks like Spring AI Alibaba still offer unique value — they provide extensive enhancements on top of Spring AI, supporting autonomous planning and reasoning for ReAct Agents, as well as Workflow-based orchestrable Agent applications. With Spring AI 2.0 filling in the foundational Agent capabilities, Spring AI Alibaba's value is more evident in production-grade advanced orchestration and domestic ecosystem integration.
Put simply, Spring AI 2.0 built the Agent "foundation," while ecosystem frameworks handle the "interior finishing."
Spring AI Agent Utils: A Toolkit Reverse-Engineered from Claude Code
A major highlight of this hands-on tutorial is the introduction of Agent Utils, a toolkit provided by the Spring AI community. According to Xu Shu, this toolkit directly reverse-engineered the implementation approach of Claude Code, making the cost of developing a code generation assistant with it extremely low.
Claude Code is a command-line AI programming assistant tool launched by Anthropic that runs directly in the developer's terminal environment, with capabilities including reading codebases, editing files, executing commands, and searching code. Unlike GitHub Copilot, which primarily provides code completion, Claude Code functions more like a programming partner with full Agent capabilities — it can understand the entire project structure, autonomously plan modification strategies, and execute multi-step operations to complete complex code refactoring or feature development tasks. Its core design principles include: proactively asking about unclear requirements, breaking large tasks into small steps, using file system tools to read and write code, and verifying results by executing tests. Reverse-engineering Claude Code's implementation approach essentially means replicating its tool design and interaction patterns.
This toolkit provides the key components needed to build a high-quality code Agent:
Ask User Question (Proactive Questioning)
When the LLM determines that the prompt information is insufficient to accurately complete a task, it can proactively ask the user several questions, filling context gaps through the user's answers. This mechanism significantly improves Agent reliability — instead of "guessing blindly," it confirms requirements like a real human assistant. This design is heavily used in Claude Code: when a user gives a vague instruction (such as "optimize this function"), the Agent will follow up asking whether the specific optimization goal is performance, readability, or memory usage, thereby avoiding output that doesn't meet expectations.
Skills (Skill Modules)
Encapsulating specific capabilities as reusable Skills allows the Agent to invoke different specialized skill modules on demand — an important organizational approach for building complex Agent applications. Each Skill can contain independent system prompts, tool collections, and execution logic, such as "Code Review Skill," "Unit Test Generation Skill," "API Documentation Writing Skill," etc. The Agent dynamically activates the appropriate skill based on the task type.
Task Planning and Long-term Memory
The toolkit also includes Task Planning and Long-term Memory capabilities. The former enables the Agent to decompose complex objectives into ordered execution steps; the latter addresses the pain point of cross-session context loss, giving the Agent the ability to "remember history."
Long-term memory in AI Agents is a persistence memory mechanism relative to in-session short-term memory. Short-term memory is typically implemented by appending conversation history to the Prompt, but is limited by the model's context window length. Long-term memory requires extracting and compressing important information for storage in an external database (usually a vector database), then recalling relevant memories through semantic retrieval in subsequent sessions. In code Agent scenarios, long-term memory can remember a user's coding style preferences, project architecture conventions, historical modification records, and more, making the Agent increasingly "understand" the developer's needs across multiple interactions.
Hands-on Project: From Basic Dialogue to Complete Agent

The entire tutorial follows a "shallow to deep" learning path, making it ideal for systematic study. The learning trajectory is roughly as follows:
- Basic LLM Dialogue: Starting with the most fundamental ChatClient calls
- Streaming Output: Implementing typewriter-effect real-time responses. Streaming output is based on Server-Sent Events (SSE) or WebFlux's Flux reactive streams — the model pushes each generated Token to the frontend immediately rather than waiting for the complete response, which significantly improves user experience in long-text generation scenarios.
- Memory: Giving conversations contextual continuity
- Tools and MCP: Equipping the model with the ability to call external tools, integrating Model Context Protocol. MCP is a standardized protocol open-sourced by Anthropic in late 2024, designed to solve the connectivity problem between large language models and external data sources and tools. It defines a unified client-server architecture where AI applications act as MCP clients and various tools and data sources act as MCP servers, communicating through standardized JSON-RPC protocol. Similar to how the USB interface unified peripheral connection standards, Spring AI 2.0's support for MCP means developers can connect to any MCP-compliant tool service through a unified interface.
- Advanced Agent Utils: Ask User Question, Skills, Task Planning, Long-term Memory
The ultimate goal is to build a code generation assistant project similar to Claude Code. This zero-to-one, layer-by-layer progressive hands-on approach helps developers master the fundamentals of Spring AI 2.0 while delivering enterprise-grade Agent applications.
Learning Recommendations and Resource Access

For Java developers planning to get started with Spring AI 2.0, here are a few suggestions:
- Build your 1.0 foundation first: Since 90% of 2.0's content is consistent with 1.0, solidly mastering foundational components like ChatClient, ChatModel, and Tools is a prerequisite.
- Focus on conquering the Agent layer: This is where the real value of 2.0 lies and the hottest direction in current AI application development. Understanding how the ReAct loop works, the registration and scheduling mechanisms of Tool Calling, and Agent state management are key to mastering this layer.
- Leverage community toolkits: Agent Utils' reverse-engineered Claude Code approach enables you to rapidly build production-grade code assistants at minimal cost.
- Stay informed on the Java Agent ecosystem evolution: Beyond Spring AI and Spring AI Alibaba, frameworks like LangChain4j in the Java ecosystem are worth comparative study. Understanding different frameworks' design trade-offs helps make better technology choices in real projects.
According to the content creator, course notes and source code for this series can be obtained for free by commenting "Spring AI" in the video comment section. For enterprise developers looking to combine the Spring ecosystem with AI Agents, this is a remarkably pragmatic learning path.
Conclusion
The release of Spring AI 2.0 marks a critical step forward for the Java ecosystem in AI Agent development. It's no longer limited to the beginner-level approach of "calling models + assembling Prompts" — instead, it provides a genuine Agent foundation with autonomous reasoning, tool calling, and iterative looping. Combined with the community's Agent Utils toolkit, developers can replicate a Claude Code-style intelligent code assistant at minimal cost. For teams rooted in the Java tech stack who want to embrace the AI wave, Spring AI 2.0 is undoubtedly worth serious attention and investment.
From a broader perspective, Spring AI 2.0's Agent foundation construction reflects the overall trend in AI application development: evolving from simple model call wrappers toward intelligent agent frameworks with autonomous decision-making capabilities. This evolution has been thoroughly validated in the Python ecosystem through frameworks like LangChain, CrewAI, and AutoGen, and Spring AI 2.0 opens up the same level of possibilities for Java enterprise developers — enabling the vast number of enterprise systems built on the Spring ecosystem to embrace the Agent era with minimal migration cost.
Related articles

ICANN Revokes Bulletproof Registrar Trustname's Accreditation: Impact and Analysis
ICANN has officially revoked bulletproof registrar Trustname's accreditation, severing its ability to harbor cybercrime. This article analyzes the impact on internet security governance.

ChatGPT Voice Mode Clones User's Voice: Root Cause Analysis and Security Implications
Reddit user reports ChatGPT voice mode cloning their voice. Analysis of OpenAI's disclosed unauthorized voice generation risk, technical causes, and safety guardrail limitations.

Building a Neural Network from Scratch: A Practical Guide to Backpropagation and Gradient Computation
A detailed guide on building neural networks from scratch with Python and NumPy, covering forward propagation, backpropagation, gradient checking, and numerical stability.