{"record":{"id":"ca9a115f1098023f","repo":"alibaba/spring-ai-alibaba","slug":"routingagent-attempt-returned-invalid-age-ca9a11","errorCode":null,"errorMessage":"RoutingAgent {} attempt {}/{} returned invalid agent names: {}","messagePattern":"RoutingAgent (.+?) attempt (.+?)/(.+?) returned invalid agent names: (.+?)","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":260,"sourceCode":"\n\t\t\t\tList<String> decisionValues = decision.getAgentNames();\n\n\t\t\t\tif (decisionValues != null && !decisionValues.isEmpty()) {\n\t\t\t\t\t// Validate all agent names\n\t\t\t\t\tList<String> invalidAgents = decisionValues.stream()\n\t\t\t\t\t\t\t.filter(agentName -> subAgents.stream().noneMatch(agent -> agent.name().equals(agentName)))\n\t\t\t\t\t\t\t.collect(Collectors.toList());\n\n\t\t\t\t\tif (invalidAgents.isEmpty()) {\n\t\t\t\t\t\tif (attempt > 0) {\n\t\t\t\t\t\t\tlogger.info(\"RoutingAgent {} succeeded on retry attempt {}. Routed to sub-agents: {}\",\n\t\t\t\t\t\t\t\t\trootAgent.name(), attempt, String.join(\", \", decisionValues));\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn decision;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tlastInvalidDecision = decisionValues;\n\t\t\t\t\t\tlogger.warn(\"RoutingAgent {} attempt {}/{} returned invalid agent names: {}\",\n\t\t\t\t\t\t\t\trootAgent.name(), attempt, maxRetries, invalidAgents);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlastInvalidDecision = Collections.emptyList();\n\t\t\t\t\tlogger.warn(\"RoutingAgent {} attempt {}/{} returned empty agent list\",\n\t\t\t\t\t\t\trootAgent.name(), attempt, maxRetries);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tif (attempt == maxRetries) {\n\t\t\t\t\tlogger.error(\"RoutingAgent {} failed on final attempt {}/{}\", rootAgent.name(), attempt, maxRetries, e);\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tlogger.warn(\"RoutingAgent {} attempt {}/{} encountered an error, will retry\", rootAgent.name(), attempt, maxRetries, e);\n\t\t\t}\n\t\t}\n","sourceCodeStart":242,"sourceCodeEnd":278,"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#L242-L278","documentation":"RoutingNode.getDecisionWithRetry logs a warning when the LLM's RoutingDecision contains agent names not present among the configured sub-agents. The invalid decision is stored as lastInvalidDecision and the attempt is retried with corrective feedback.","triggerScenarios":"Thrown at spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/node/RoutingNode.java:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["List allowed agent names explicitly in the routing prompt","Add schema/enum constraints on the structured output","Rename agents to clearer, distinct identifiers"],"exampleFix":null,"handlingStrategy":"retry","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"}