Routing Workflow with Spring AI: Classify First, Then Answer A developer has published a walkthrough of the Routing Workflow pattern implemented with Spring AI, in which a model first classifies an incoming request and then dispatches it to a route-specific prompt, drawing on Anthropic's "Building Effective Agents" guidance and the spring-ai-examples repository's agentic-patterns/routing-workflow example. The writeup details the RoutingWorkflow class's route method, which looks up the classifier's returned route key directly in a prompt map and throws an IllegalArgumentException on a mismatch, and notes the pattern costs an extra model call per request while introducing misclassification as a new failure mode. Most LLM applications start with one prompt that tries to do everything. It classifies the request, answers it, and follows a policy, all in the same instruction. That works for a demo. In production, it becomes hard to tune, hard to test, and hard to explain when one kind of request gets a poor answer because the prompt was written for another kind. The Routing Workflow pattern takes a different approach. Instead of one general prompt, you first ask the model to decide what kind of input it is looking at. Then you send the input to a prompt written specifically for that kind of input. Anthropic's article "Building Effective Agents" describes routing as one of the core workflow patterns for LLM systems, and the Spring AI team has published a compact example of it in the spring-ai-examples repository, under agentic-patterns/routing-workflow . In this article I walk through the pattern, the code in the example, and the practical issues you will hit when you use it: how the classifier is built, why the route key has to match exactly, what happens when the model picks something unexpected, how to test the router, and where the pattern stops being the right tool. I will keep the code close to the example so you can follow along with the repository open. Routing separates two decisions that a single prompt would otherwise make at once. The first decision is classification: what kind of request is this? Is it a billing question, a technical problem, an account security issue, or a product question? The second decision is handling: given that it is a billing question, what should the response look like? Separating them has three practical benefits. The cost is an extra model call per request, and a new failure mode: the classifier can pick the wrong route. The rest of this article is about managing both. The flow has three steps: Notice that the router makes two model calls per input: one to classify, and one to answer. That is the main trade-off. If you route cheap, simple requests to a smaller model, the classification step can be a meaningful part of the cost savings. If every request needs the most capable model anyway, routing adds latency and money without a clear gain. The example's main class is RoutingWorkflow , in the package com.example.agentic . It takes a ChatClient in its constructor and exposes one public method: public String route String input, Map