{"record":{"id":"84b65a254c828b51","repo":"alibaba/spring-ai-alibaba","slug":"could-not-find-executeagent-method-in-agenttoolexe","errorCode":null,"errorMessage":"Could not find executeAgent method in AgentToolExecutor class","messagePattern":"Could not find executeAgent method in AgentToolExecutor class","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/AgentTool.java","lineNumber":81,"sourceCode":"\tpublic static ToolCallback getFunctionToolCallback(ReactAgent agent) {\n\t\treturn AgentTool.create(agent);\n\t}\n\n\t/**\n\t * Create a ToolCallback using MethodToolCallback.\n\t * This method uses reflection to find the executeAgent method and builds MethodToolCallback\n\t * directly without requiring @Tool annotation.\n\t * \n\t * @param agent the ReactAgent instance\n\t * @return ToolCallback created with MethodToolCallback\n\t */\n\tpublic static ToolCallback create(ReactAgent agent) {\n\t\t// Find the executeAgent method using reflection\n\t\tjava.lang.reflect.Method method = ReflectionUtils.findMethod(AgentToolExecutor.class, \n\t\t\t\t\"executeAgent\", String.class, ToolContext.class);\n\t\t\n\t\tif (method == null) {\n\t\t\tthrow new IllegalStateException(\"Could not find executeAgent method in AgentToolExecutor class\");\n\t\t}\n\n\t\t// Get the original schema from inputSchema or inputType\n\t\tString originalSchema = StringUtils.hasLength(agent.getInputSchema())\n\t\t\t\t? agent.getInputSchema()\n\t\t\t\t: (agent.getInputType() != null)\n\t\t\t\t? JsonSchemaGenerator.generateForType(agent.getInputType())\n\t\t\t\t: null;\n\n\t\t// Wrap the original schema in an \"input\" parameter\n\n\t\t// Create ToolDefinition using ToolDefinition.builder() with the method\n\t\tDefaultToolDefinition.Builder builder = ToolDefinitions.builder(method)\n\t\t\t\t.name(agent.name())\n\t\t\t\t.description(agent.description());\n\n\t\tif (StringUtils.hasLength(originalSchema)) {\n\t\t\tString wrappedInputSchema = wrapSchemaInInputParameter(originalSchema);","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/AgentTool.java#L63-L99","documentation":"AgentTool.create uses reflection (ReflectionUtils.findMethod) to locate AgentToolExecutor.executeAgent(String, ToolContext). If that method is missing it throws IllegalStateException, meaning the AgentToolExecutor class in the classpath does not have the expected method signature — typically a version mismatch or partially built artifact.","triggerScenarios":"Calling ReactAgent tool creation that runs AgentTool.create(agent) when the AgentToolExecutor class on the classpath lacks an executeAgent(String, ToolContext) method — e.g. a stale jar, a renamed/refactored executor, or mixed framework versions.","commonSituations":"Upgrading spring-ai-alibaba-agent-framework partially so AgentTool and AgentToolExecutor come from different versions; a shaded/repackaged jar dropping the method; local edits renaming executeAgent.","solutions":["Run a clean rebuild: ./mvnw clean package -DskipTests=true to ensure AgentTool and AgentToolExecutor come from the same build.","Check AgentToolExecutor for a method exactly named executeAgent with parameters (String, ToolContext); restore or rename it back.","Align dependency versions via spring-ai-alibaba-bom so no mixed framework jars exist on the classpath.","mvn dependency:tree and remove older/duplicate spring-ai-alibaba artifacts."],"exampleFix":"// before (AgentToolExecutor after refactor)\npublic ToolResponse invoke(String input, ToolContext ctx) { ... }\n// after\npublic String executeAgent(String input, ToolContext toolContext) { ... }","handlingStrategy":"try-catch","validationCode":"Method m = ReflectionUtils.findMethod(AgentToolExecutor.class, \"executeAgent\", String.class, ToolContext.class);\nif (m == null) throw new IllegalStateException(\"Incompatible spring-ai-alibaba-agent-framework on classpath: executeAgent missing\");","typeGuard":null,"tryCatchPattern":"try { ToolCallback tool = AgentTool.create(agent); } catch (IllegalStateException e) { throw new IllegalStateException(\"Framework jar mismatch; rebuild/align versions\", e); }","preventionTips":["Manage all spring-ai-alibaba versions via spring-ai-alibaba-bom.","Clean-rebuild after framework upgrades (mvnw clean install).","Run dependency:tree in CI to detect mixed framework versions."],"tags":["reflection","version-mismatch","classpath"],"backgroundTag":"class-not-found","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"}