Spring AI 2.0: build Claude-style tool call status
Learn to stream tool call status with Spring AI 2.0 advisors and server-sent events in a travel chat app with hardcoded weather and event data.
Player not loading? Watch on YouTube
This tutorial builds a travel chat app that displays tool call status while the model prepares its answer. A question about Chicago next week prompts calls for the current date, weather and city events. The date tool returns actual date and time information; the weather and event tools use hardcoded data. The speaker explains that a production weather tool would need to call another service.
The walkthrough focuses on Spring AI 2.0's ToolCallingAdvisor, which puts the tool execution loop in the advisor chain. The speaker contrasts this with Spring AI 1.x, where individual chat models handled their own loops. He finds the new approach easier to observe, but acknowledges that he did not test whether the same interface was possible in 1.x.
The example uses Spring Boot 4.0 or higher, Spring MVC, an Anthropic connection and JTE templates. It defines methods with @Tool, registers them with a ChatClient and adds chat memory so follow-up questions retain their context. A conversation ID identifies the memory context, with a default value when the request omits one.
A custom observing advisor captures intermediate tool events. ChatEventStream combines those events with response tokens and sends them to the browser through server-sent events. The result resembles the tool status interface in Claude and ChatGPT. This demonstration connects to Anthropic; it does not cover running a local model.