DEV Community

Cover image for Building a multi-step AI agent in Java with Spring AI 2.0
David Brown
David Brown

Posted on • Originally published at tucanoo.com

Building a multi-step AI agent in Java with Spring AI 2.0

I wanted to try Spring AI's agentic tooling on something that resembles a real production project rather than the usual weather-API call, so I built an example Spring Boot API: a civic research assistant. You give it a plain-English issue and a UK postcode, and it works out the most effective way to raise that issue with Parliament. It uses an LLM (ChatGPT) along with the free UK postcode and Open Parliament APIs. The flow isn't dictated in code. We register a handful of @Tool methods (resolve the postcode, find the MP, search bills, find committees and open inquiries, check the voting record) and let the model decide which to call and in what order. It chains them itself and returns a final answer with a citation on every claim. The stack is Java 25, Spring Boot 4.1 and Spring AI 2.0.
The full tutorial walks through the Spring AI 2.0 tool-calling setup and what changed since 1.x, registering the tools, getting structured typed output back instead of free text, and a small guard that checks every citation actually came from a tool call so the model can't quietly invent a source. It's all runnable, with the complete code on GitHub.

Full tutorial: https://tucanoo.com/building-an-agentic-workflow-in-java-multi-step-ai-agents-with-spring-ai-and-tool-calling/
Source: https://github.com/tucanoo/spring-ai-civic-research-assistant

If you're using Spring AI's tool calling on anything that touches real data, I'd be interested in how you're handling grounding to keep the model from citing things it never fetched.

Top comments (0)