tags: [java, springboot, ai, springai]

Six months ago, I added an AI assistant to an e-commerce platform I was building. The idea was simple: let users type "show me orders with delayed shipping" or "what is the inventory level for wireless headphones?" and get real answers from live data.

The first version worked. Barely. The model hallucinated order IDs, made up inventory numbers, and confidently claimed it could process refunds (it could not). The problem was not the LLM — it was that I had given it no real tools. It was guessing everything from its training data.

Every AI agent I have seen in production follows the same pattern: the LLM decides what action to take, calls a tool, gets a result, and continues. The hard part is wiring that loop correctly — defining tools that the model understands, handling edge cases, and keeping the code testable.

I am a Senior Software Engineer II at BS23 in Dhaka, with six years of Spring Boot experience and an OCP certification. I have been building with Spring AI since its early releases. This article kicks off a series on building production AI agents with Spring Boot 4 and Spring AI 2.0. Here is how I think about tools and function calling.