{"record":{"id":"ab24da7ce557f7a2","repo":"alibaba/spring-ai-alibaba","slug":"agentscope-model-must-be-provided-for-agentscope-r","errorCode":null,"errorMessage":"AgentScope Model must be provided for AgentScope routing agent","messagePattern":"AgentScope Model must be provided for AgentScope routing agent","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-agentscope/src/main/java/com/alibaba/cloud/ai/agent/agentscope/flow/AgentScopeRoutingAgent.java","lineNumber":110,"sourceCode":"\t\t\tthis.systemPrompt = systemPrompt;\n\t\t\treturn this;\n\t\t}\n\n\t\tpublic AgentScopeRoutingAgentBuilder instruction(String instruction) {\n\t\t\tthis.instruction = instruction;\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tprotected AgentScopeRoutingAgentBuilder self() {\n\t\t\treturn this;\n\t\t}\n\n\t\t@Override\n\t\tprotected void validate() {\n\t\t\tsuper.validate();\n\t\t\tif (model == null) {\n\t\t\t\tthrow new IllegalArgumentException(\"AgentScope Model must be provided for AgentScope routing agent\");\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic AgentScopeRoutingAgent doBuild() {\n\t\t\tvalidate();\n\t\t\treturn new AgentScopeRoutingAgent(this);\n\t\t}\n\t}\n}\n","sourceCodeStart":92,"sourceCodeEnd":121,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-agentscope/src/main/java/com/alibaba/cloud/ai/agent/agentscope/flow/AgentScopeRoutingAgent.java#L92-L121","documentation":"AgentScopeRoutingAgent.Builder.validate() enforces that a routing agent has a Model configured. The routing agent must call an LLM to select which sub-agent to execute, so building without a model is invalid and throws IllegalArgumentException during build().","triggerScenarios":"Building an AgentScopeRoutingAgent via its builder without calling the model(...) setter (or passing null), then invoking build()/doBuild() which triggers validate().","commonSituations":"Forgot to set the model on the builder; model bean is null due to failed conditional auto-configuration (no model API key); refactoring removed the model assignment; copying a builder from another agent type that doesn't require a model.","solutions":["Call .model(...) on the AgentScopeRoutingAgent builder with a configured Model instance (e.g. DashScope/OpenAI chat model).","Ensure the model bean exists: check API key configuration for the model provider.","If constructing via FlowGraphBuilder config, set the \"agentScopeModel\" custom property so the model is propagated."],"exampleFix":"// before\nAgentScopeRoutingAgent agent = AgentScopeRoutingAgent.builder()\n    .name(\"router\")\n    .subAgents(subAgents)\n    .build(); // IllegalArgumentException\n// after\nAgentScopeRoutingAgent agent = AgentScopeRoutingAgent.builder()\n    .name(\"router\")\n    .model(chatModel)\n    .subAgents(subAgents)\n    .build();","handlingStrategy":"validation","validationCode":"// Java: validate builder inputs before building\nif (model == null) {\n    throw new IllegalStateException(\"Provide a Model via AgentScopeRoutingAgent.builder().model(...) before build()\");\n}\nif (subAgents == null || subAgents.isEmpty()) {\n    throw new IllegalStateException(\"Routing agent requires at least one sub-agent\");\n}","typeGuard":"// Java\nboolean hasModel(AgentScopeRoutingAgent.Builder b, Model m) {\n    return m != null; // check the model instance before passing to the builder\n}","tryCatchPattern":null,"preventionTips":["Always call .model(...) on AgentScopeRoutingAgent.builder().","Wire the model through Spring configuration so a misconfigured API key fails fast at context startup.","Add a unit test asserting the routing agent builds with the expected model."],"tags":["agentscope","routing-agent","validation","missing-model","illegal-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}