All Superinterfaces:
Prototype.Api
All Known Implementing Classes:
AgentsConfig.BuilderBase.AgentsConfigImpl

public interface AgentsConfig extends Prototype.Api
Configuration for a single LangChain4j agent.

The configuration primarily consists of:

  • Basic agent metadata (name, description, output key)
  • Execution settings (async invocation and concurrent tool execution)
  • References to services resolved from the ServiceRegistry (model, memory, retriever, tools, etc.)
  • Guardrail class lists resolved from the ServiceRegistry
See Also:
  • Method Details

    • builder

      static AgentsConfig.Builder builder()
      Create a new fluent API builder to customize configuration.
      Returns:
      a new builder
    • builder

      static AgentsConfig.Builder builder(AgentsConfig instance)
      Create a new fluent API builder from an existing instance.
      Parameters:
      instance - an existing instance used as a base for the builder
      Returns:
      a builder based on an instance
    • create

      static AgentsConfig create(Config config)
      Create a new instance from configuration.
      Parameters:
      config - used to configure the new instance
      Returns:
      a new instance configured from configuration
    • create

      @Deprecated static AgentsConfig create(Config config)
      Create a new instance from configuration.
      Parameters:
      config - used to configure the new instance
      Returns:
      a new instance configured from configuration
    • create

      static AgentsConfig create()
      Create a new instance with default values.
      Returns:
      a new instance
    • configure

      default void configure(dev.langchain4j.agentic.AgenticServices.DeclarativeAgentCreationContext<?> ctx, ServiceRegistry serviceRegistry)
      Configures LangChain4j AgentBuilder from AgentsConfig.

      This method resolves any configured service references (such as ChatModel, ChatMemory, ChatMemoryProvider, ContentRetriever, RetrievalAugmentor, ToolProvider, and McpClient) from the provided ServiceRegistry and applies them to the builder obtained from the supplied context.

      Parameters:
      ctx - context providing the agent builder to configure
      serviceRegistry - registry used to resolve configured service references
      Throws:
      NullPointerException - if any configured tool class or MCP client cannot be resolved from the registry
      IllegalStateException - if any configured tool class or MCP client cannot be resolved from the registry
    • enabled

      boolean enabled()
      If set to false, agent will not be available even if configured.
      Returns:
      whether agent is enabled, defaults to true
    • name

      Optional<String> name()
      Agent identifier used to label the agent in workflows and/or agent registries.

      If configured, this value is applied to the underlying agent builder via agentBuilder.name(...).

      Returns:
      configured agent name, or empty if not configured
    • description

      Optional<String> description()
      Description of the agent. It should be clear and descriptive to allow a language model to understand the agent's purpose and its intended use.
      Returns:
      description of the agent.
    • outputKey

      Optional<String> outputKey()
      Key of the output variable that will be used to store the result of the agent's invocation.
      Returns:
      name of the output variable.
    • async

      Optional<Boolean> async()
      If true, the agent will be invoked in an asynchronous manner, allowing the workflow to continue without waiting for the agent's result.
      Returns:
      true if the agent should be invoked asynchronously, false otherwise.
    • executeToolsConcurrently

      Optional<Boolean> executeToolsConcurrently()
      If true, the agent's tools can be invoked in a concurrent manner.
      Returns:
      true if agent's tools can be invoked concurrently.
    • chatModel

      Optional<String> chatModel()
      Name of the ChatModel service to use for this agent.

      The value is resolved from the ServiceRegistry.

      Returns:
      configured name of the chat model service, or empty if not configured
    • chatMemory

      Optional<String> chatMemory()
      Name of the ChatMemory service to use for this agent.

      The value is resolved from the ServiceRegistry.

      Returns:
      configured name of the chat memory service, or empty if not configured
    • chatMemoryProvider

      Optional<String> chatMemoryProvider()
      Name of the ChatMemoryProvider service to use for this agent.

      The value is resolved from the ServiceRegistry.

      Returns:
      configured name of the chat memory provider service, or empty if not configured
    • contentRetriever

      Optional<String> contentRetriever()
      Name of the ContentRetriever service to use for this agent.

      The value is resolved from the ServiceRegistry.

      Returns:
      configured name of the content retriever service, or empty if not configured
    • retrievalAugmentor

      Optional<String> retrievalAugmentor()
      Name of the RetrievalAugmentor service to use for this agent.

      The value is resolved from the ServiceRegistry.

      Returns:
      configured name of the retrieval augmentor service, or empty if not configured
    • toolProvider

      Optional<String> toolProvider()
      Name of the ToolProvider service to use for this agent.

      The value is resolved from the ServiceRegistry.

      Returns:
      configured name of the tool provider service, or empty if not configured
    • tools

      Set<Class<?>> tools()
      Tool service classes to register with the agent.

      Each class is resolved from the ServiceRegistry, and the resulting service instances are registered using agentBuilder.tools(...).

      Returns:
      configured set of tool classes, or an empty set if not configured
    • mcpClients

      Set<String> mcpClients()
      Names of McpClient services to use for MCP-backed tools.

      Each name is resolved from the ServiceRegistry, the clients are then used to build an McpToolProvider which is registered as the agent's tool provider.

      Returns:
      configured set of MCP client service names, or an empty set if not configured
    • inputGuardrails

      Set<Class<? extends dev.langchain4j.guardrail.InputGuardrail>> inputGuardrails()
      Input guardrail classes to apply to the agent.

      Each class is resolved from the ServiceRegistry.

      Returns:
      configured set of input guardrail classes, or an empty set if not configured
    • outputGuardrails

      Set<Class<? extends dev.langchain4j.guardrail.OutputGuardrail>> outputGuardrails()
      Output guardrail classes to apply to the agent.

      Each class is resolved from the ServiceRegistry,

      Returns:
      configured set of output guardrail classes, or an empty set if not configured