Two weeks after I shipped the e-commerce agent from Part 1, my first real tester asked it a question that broke the illusion: "What was in my cart again?"
The agent had answered that exact question two messages earlier. It had called the cart tool, listed four items, and totaled the price. And now it was starting from zero, because to the model every message is a fresh conversation. Statelessness is the default contract of every LLM API. If you do not send the history back, the model does not have it.
That is the gap this part of the series closes. In Part 1, I showed how to give an agent hands with the @Tool annotation. Here I show how to give it a memory: conversation history that survives across turns, session isolation so users never see each other's context, and the context-management decisions that keep the whole thing inside your token budget.
I am a Senior Software Engineer II at BS23 in Dhaka, and I have been building production AI agents with Spring Boot and Spring AI for over a year. Everything below comes from an agent I actually run, not a toy demo.
Memory Means You Re-Send the History






