Record Class AgentExecutor

java.lang.Object
java.lang.Record
dev.langchain4j.agentic.internal.AgentExecutor
All Implemented Interfaces:
InternalAgent, AgentInstance

public record AgentExecutor(AgentInvoker agentInvoker, Object agent) extends Record implements AgentInstance, InternalAgent
  • Constructor Details

    • AgentExecutor

      public AgentExecutor(AgentInvoker agentInvoker, Object agent)
      Creates an instance of a AgentExecutor record class.
      Parameters:
      agentInvoker - the value for the agentInvoker record component
      agent - the value for the agent record component
  • Method Details

    • execute

      public Object execute(DefaultAgenticScope agenticScope, PlannerExecutor planner)
    • syncExecute

      public Object syncExecute(DefaultAgenticScope agenticScope, PlannerExecutor planner)
    • type

      public Class<?> type()
      Specified by:
      type in interface AgentInstance
    • plannerType

      public Class<? extends Planner> plannerType()
      Specified by:
      plannerType in interface AgentInstance
    • name

      public String name()
      Specified by:
      name in interface AgentInstance
    • agentId

      public String agentId()
      Specified by:
      agentId in interface AgentInstance
    • description

      public String description()
      Description copied from interface: AgentInstance
      The description of this agent. For a remote agent without an explicit description, like an A2A or an MCP one, it is read from the remote server the first time it is requested, so this call can block, and it fails with an AgentUnavailableException when the server is unavailable.
      Specified by:
      description in interface AgentInstance
    • outputType

      public Type outputType()
      Specified by:
      outputType in interface AgentInstance
    • outputKey

      public String outputKey()
      Specified by:
      outputKey in interface AgentInstance
    • arguments

      public List<AgentArgument> arguments()
      Specified by:
      arguments in interface AgentInstance
    • subagents

      public List<AgentInstance> subagents()
      Specified by:
      subagents in interface AgentInstance
    • async

      public boolean async()
      Specified by:
      async in interface AgentInstance
    • optional

      public boolean optional()
      Specified by:
      optional in interface AgentInstance
    • activationCondition

      public AgentCondition activationCondition()
      Description copied from interface: AgentInstance
      The condition under which this agent runs when it is invoked as a subagent, or null when it always runs. When the condition is false, the agent is skipped: it is not invoked, it writes nothing to the AgenticScope and its parent's planner is notified of the skip. The condition is ignored when the agent is invoked directly, as the root of an agentic system.

      The condition can be evaluated more than once for a single invocation, by the planner of the parent while selecting its next agents and again when the agent is invoked, so it must be cheap and free of side effects.

      Specified by:
      activationCondition in interface AgentInstance
    • topology

      public AgenticSystemTopology topology()
      Specified by:
      topology in interface AgentInstance
    • parent

      public AgentInstance parent()
      Specified by:
      parent in interface AgentInstance
    • setParent

      public void setParent(InternalAgent parent)
      Specified by:
      setParent in interface InternalAgent
    • compensateOnError

      public boolean compensateOnError()
      Specified by:
      compensateOnError in interface InternalAgent
    • enableCrossAgentCompensation

      public void enableCrossAgentCompensation()
      Specified by:
      enableCrossAgentCompensation in interface InternalAgent
    • registerInheritedParentListener

      public void registerInheritedParentListener(AgentListener parentListener)
      Specified by:
      registerInheritedParentListener in interface InternalAgent
    • appendId

      public void appendId(String idSuffix)
      Specified by:
      appendId in interface InternalAgent
    • listener

      public AgentListener listener()
      Specified by:
      listener in interface InternalAgent
    • as

      public <T extends AgentInstance> T as(Class<T> agentInstanceClass)
      Specified by:
      as in interface AgentInstance
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • agentInvoker

      public AgentInvoker agentInvoker()
      Returns the value of the agentInvoker record component.
      Returns:
      the value of the agentInvoker record component
    • agent

      public Object agent()
      Returns the value of the agent record component.
      Returns:
      the value of the agent record component