{"record":{"id":"3c0963b46d6d4a37","repo":"alibaba/spring-ai-alibaba","slug":"routingagent-exhausted-routing-retries-routing","errorCode":null,"errorMessage":"RoutingAgent {} exhausted routing retries. Routing to fallback agent {}.","messagePattern":"RoutingAgent (.+?) exhausted routing retries\\. Routing to fallback agent (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/node/RoutingNode.java","lineNumber":113,"sourceCode":"\t\tthis.chatClient = ChatClient.builder(chatModel).defaultSystem(sb.toString()).build();\n\t}\n\n\t@Override\n\tpublic MultiCommand apply(OverAllState state, RunnableConfig config) throws Exception {\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tList<Message> messages = (List<Message>) state.value(\"messages\").orElse(List.of());\n\t\t\n\t\t// Prepare messages with instruction if available\n\t\tList<Message> messagesWithInstruction = prepareMessagesWithInstruction(messages);\n\t\t\n\t\tRoutingDecision decision;\n\t\ttry {\n\t\t\tdecision = getDecisionWithRetry(messagesWithInstruction, DEFAULT_MAX_RETRIES);\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tMultiCommand fallbackCommand = createFallbackCommand(state, messages);\n\t\t\tif (fallbackCommand != null) {\n\t\t\t\tlogger.warn(\"RoutingAgent {} exhausted routing retries. Routing to fallback agent {}.\",\n\t\t\t\t\t\trootAgent.name(), fallbackCommand.gotoNodes().get(0));\n\t\t\t\treturn fallbackCommand;\n\t\t\t}\n\t\t\tthrow e;\n\t\t}\n\t\tList<String> decisionValues = decision.getAgentNames();\n\n\t\t// Validate all agent names are valid\n\t\tList<String> invalidAgents = decisionValues.stream()\n\t\t\t\t.filter(agentName -> subAgents.stream().noneMatch(agent -> agent.name().equals(agentName)))\n\t\t\t\t.collect(Collectors.toList());\n\t\t\t\t\n\t\tif (invalidAgents.isEmpty() && !decisionValues.isEmpty()) {\n\t\t\tif (decisionValues.size() == 1) {\n\t\t\t\tlogger.info(\"RoutingAgent {} routed to single sub-agent {}.\", rootAgent.name(), decisionValues.get(0));\n\t\t\t} else {\n\t\t\t\tlogger.info(\"RoutingAgent {} routed to {} sub-agents in parallel: {}.\", \n\t\t\t\t\t\trootAgent.name(), decisionValues.size(), String.join(\", \", decisionValues));","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/node/RoutingNode.java#L95-L131","documentation":"RoutingNode.apply, after getDecisionWithRetry exhausts DEFAULT_MAX_RETRIES without a valid RoutingDecision: if a fallback agent is configured it logs this warning and routes there; the message marks degradation from LLM-based routing to the fallback path.","triggerScenarios":"Thrown at spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/node/RoutingNode.java:113 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Configure a fallback agent so exhausted retries degrade gracefully","Improve the routing system prompt and available-agent descriptions","Increase DEFAULT_MAX_RETRIES or loosen decision validation","Check the ChatModel for malformed/empty structured outputs"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}