Class AgentSpecReactAgentFactory

java.lang.Object
com.alibaba.cloud.ai.graph.agent.tools.task.AgentSpecReactAgentFactory

public final class AgentSpecReactAgentFactory extends Object
Factory that converts AgentSpec into ReactAgent instances.

Use this when loading agent specs from files - the factory creates ReactAgents with the spec's system prompt and optionally filtered tools.


 AgentSpecReactAgentFactory factory = AgentSpecReactAgentFactory.builder()
     .chatModel(chatModel)
     .defaultTools(grepTool, globTool, readTool)
     .build();

 List<AgentSpec> specs = AgentSpecLoader.loadFromDirectory(".claude/agents");
 Map<String, ReactAgent> subAgents = new HashMap<>();
 for (AgentSpec spec : specs) {
     subAgents.put(spec.name(), factory.create(spec));
 }
 
Author:
Spring AI Alibaba