Class AgenticServices

java.lang.Object
dev.langchain4j.agentic.AgenticServices

public class AgenticServices extends Object
Provides static factory methods to create and configure various types of agent services.
  • Method Details

    • setWorkflowAgentsBuilder

      public static void setWorkflowAgentsBuilder(WorkflowAgentsBuilder workflowAgentsBuilder)
      Explicitly set a WorkflowAgentsBuilder.
    • agentBuilder

      public static <T> AgentBuilder<T> agentBuilder(Class<T> agentServiceClass)
      Creates an agent builder for the given agent service class.
      Parameters:
      agentServiceClass - the class of the agent service
      Returns:
      a new AgentBuilder instance
    • humanInTheLoopBuilder

      public static HumanInTheLoop.HumanInTheLoopBuilder humanInTheLoopBuilder()
      Creates a builder for an agent implementing the human-in-the-loop pattern.
    • sequenceBuilder

      public static SequentialAgentService<UntypedAgent> sequenceBuilder()
      Creates a builder for an untyped agent implementing a workflow sequence of its subagents.
    • sequenceBuilder

      public static <T> SequentialAgentService<T> sequenceBuilder(Class<T> agentServiceClass)
      Creates a builder for an agent implementing a workflow sequence of its subagents that can be invoked in a strongly typed way through the provided agent service interface.
      Parameters:
      agentServiceClass - the class of the agent service
    • parallelBuilder

      public static ParallelAgentService<UntypedAgent> parallelBuilder()
      Creates a builder for an untyped agent implementing a parallel workflow of its subagents.
    • parallelBuilder

      public static <T> ParallelAgentService<T> parallelBuilder(Class<T> agentServiceClass)
      Creates a builder for an agent implementing a parallel workflow of its subagents that can be invoked in a strongly typed way through the provided agent service interface.
      Parameters:
      agentServiceClass - the class of the agent service
    • loopBuilder

      public static LoopAgentService<UntypedAgent> loopBuilder()
      Creates a builder for an untyped agent implementing a loop workflow of its subagents.
    • loopBuilder

      public static <T> LoopAgentService<T> loopBuilder(Class<T> agentServiceClass)
      Creates a builder for an agent implementing a loop workflow of its subagents that can be invoked in a strongly typed way through the provided agent service interface.
      Parameters:
      agentServiceClass - the class of the agent service
    • conditionalBuilder

      public static ConditionalAgentService<UntypedAgent> conditionalBuilder()
      Creates a builder for an untyped agent implementing a conditional workflow of its subagents.
    • conditionalBuilder

      public static <T> ConditionalAgentService<T> conditionalBuilder(Class<T> agentServiceClass)
      Creates a builder for an agent implementing a conditional workflow of its subagents that can be invoked in a strongly typed way through the provided agent service interface.
      Parameters:
      agentServiceClass - the class of the agent service
    • supervisorBuilder

      public static SupervisorAgentService<SupervisorAgent> supervisorBuilder()
      Creates a builder for a supervisor agent service that can be used to manage and supervise other agents. This is useful for building complex agentic systems where one agent oversees the execution of others.
    • supervisorBuilder

      public static <T> SupervisorAgentService<T> supervisorBuilder(Class<T> agentServiceClass)
      Creates a builder for a supervisor agent service that can be used to manage and supervise other agents. This is useful for building complex agentic systems where one agent oversees the execution of others.
      Parameters:
      agentServiceClass - the class of the agent service
    • a2aBuilder

      public static A2AClientBuilder<UntypedAgent> a2aBuilder(String a2aServerUrl)
      Creates a builder for an A2A client that can be used to interact with agents over the A2A protocol. This is useful for building agentic systems that communicate with remote agents.
      Parameters:
      a2aServerUrl - the URL of the A2A server
      Returns:
      a new A2AClientBuilder instance
    • a2aBuilder

      public static <T> A2AClientBuilder<T> a2aBuilder(String a2aServerUrl, Class<T> agentServiceClass)
      Creates a builder for an A2A client that can be used to interact with agents over the A2A protocol. This is useful for building agentic systems that communicate with remote agents.
      Parameters:
      a2aServerUrl - the URL of the A2A server
      agentServiceClass - the class of the agent service
      Returns:
      a new A2AClientBuilder instance
    • createAgenticSystem

      public static <T> T createAgenticSystem(Class<T> agentServiceClass, ChatModel chatModel)
      Creates an instance of an agentic system defined through the declarative API.