Class ResolvedParameters

java.lang.Object
dev.langchain4j.agentic.internal.ResolvedParameters

public final class ResolvedParameters extends Object
The parameters of a helper method of an agent, a static method declared on the agent type or an instance method of one of its helper objects, split once, when the agent is created, between the parameters provided by a registered SupplierParameterResolver and the parameters provided by the agentic framework, like the AgenticScope, its state, the memory id or a value passed by the caller.

Only the parameters provided by the framework are agent arguments: the resolved ones are never read from the AgenticScope, nor reported to listeners and planners.

  • Method Details

    • of

      public static ResolvedParameters of(Class<?> agentType, Method method)
      Splits the parameters of the given method using the SupplierParameterResolvers registered in DeclarativeUtil. The method is invoked without a target: it is a static method, or an instance method whose target is given at each invocation, like the Agent method of a non-AI agent.
      Parameters:
      agentType - the agent class or interface declaring the method, or inheriting it
      method - the method to invoke
    • of

      public static ResolvedParameters of(Class<?> agentType, HelperMethod helper)
      Splits the parameters of the given helper method using the SupplierParameterResolvers registered in DeclarativeUtil.
      Parameters:
      agentType - the agent class or interface the method is a helper of
      helper - the method to invoke, with its target
    • method

      public Method method()
    • frameworkArguments

      public List<AgentArgument> frameworkArguments()
      Returns:
      the parameters provided by the framework, as agent arguments, in the order they are declared
    • frameworkParameterCount

      public int frameworkParameterCount()
      Returns:
      the number of parameters provided by the framework
    • frameworkParameter

      public Parameter frameworkParameter(int position)
      Returns:
      the parameter at the given position among the ones provided by the framework
    • checkFrameworkParameters

      public ResolvedParameters checkFrameworkParameters(Class<?>... expected)
      Checks that the parameters provided by the framework are exactly the expected ones, in this order.
      Throws:
      IllegalArgumentException - if they are not
    • checkAllResolved

      public ResolvedParameters checkAllResolved()
      Checks that all the parameters are provided by a resolver, as required for the methods, like the suppliers of tools or of the planner, that are invoked without any value from the framework.
      Throws:
      AgenticSystemConfigurationException - if a parameter is not supported by any resolver
    • resolvedNow

      public ResolvedParameters resolvedNow()
      Returns a copy of these parameters whose resolved parameters are resolved now, once, instead of at each invocation of the method. For the methods invoked later than the creation of the agent, like the one annotated with @A2AClientCustomizer, which runs when the A2A client is created on the first invocation of the agent: a value resolved per request, like a token, is then the one of the thread creating the agent, as for the other supplier methods, and not the one of the first caller.
    • arguments

      public Object[] arguments(Object... frameworkValues)
      Builds the positional arguments of the method, resolving its resolved parameters, unless already resolved by resolvedNow(), and taking the parameters provided by the framework from the given values, in their order. The parameters provided by the framework without a corresponding value are null.
    • invocationArguments

      public AgentInvocationArguments invocationArguments(AgenticScope agenticScope, Map<String,Object> additionalArgs, boolean writeConvertedValues)
      Builds the invocation arguments of the method: the parameters provided by the framework are read from the AgenticScope, or taken from the additional arguments, and they are the only named arguments. Without an AgenticScope the parameters provided by the framework are null.
    • invoke

      public <T> T invoke(Object... frameworkValues)
      Invokes the method on its target, with the parameters provided by the framework taken from the given values. Failures are reported as by HelperMethod.invoke(Object...).