Class AgentUtil
java.lang.Object
dev.langchain4j.agentic.internal.AgentUtil
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionagenticSystemDataTypes(AgentInstance rootAgent) static AgentInvocationArgumentsagentInvocationArguments(AgenticScope agenticScope, Method method) static AgentInvocationArgumentsagentInvocationArguments(AgenticScope agenticScope, List<AgentArgument> agentArguments) static AgentInvocationArgumentsagentInvocationArguments(AgenticScope agenticScope, List<AgentArgument> agentArguments, Map<String, Object> additionalArgs) static AgentInvocationArgumentsagentInvocationArguments(AgenticScope agenticScope, List<AgentArgument> agentArguments, Map<String, Object> additionalArgs, boolean writeConvertedValues) Resolves the arguments from theAgenticScope, converting each value to the type of its argument.static List<AgentExecutor> agentsToExecutors(Collection<?> agents) static AgentExecutoragentToExecutor(InternalAgent agent) static AgentExecutoragentToExecutor(Object agent) static AgentArgumentargumentFromParameter(Parameter parameter) static List<AgentArgument> argumentsFromMethod(Method method) static List<AgentArgument> argumentsFromMethod(Method method, Map<String, Object> defaultValues) static List<AgentArgument> static List<AgentArgument> argumentsFromMethod(Method method, Set<String> optionalArgs) static <T> TbuildAgent(Class<T> agentServiceClass, InvocationHandler invocationHandler) getAnnotatedMethodOnClass(Class<?> clazz, Class<? extends Annotation> annotation) static AgentExecutorhumanInTheLoopExecutor(Method method, Object target, AgentHelpers helpers) Creates the executor of the human-in-the-loop agent implemented by the given method, a static method or an instance method of the given target, that is also one of the helper objects of the agent.static <T> TkeyDefaultValue(Class<? extends TypedKey<T>> key) static Stringstatic AgentInvokernonAiAgentInvoker(ResolvedParameters parameters, String name, String description, String outputKey, boolean async, boolean optional, AgentCondition activationCondition, AgentListener listener) Creates the invoker of a non-AI agent method: its parameters provided by aSupplierParameterResolverare not agent arguments, and are resolved at each invocation.static AgentInvokernonAiAgentInvoker(Method agenticMethod, String name, String description, String outputKey, boolean async) static AgentInvokernonAiAgentInvoker(Method agenticMethod, String name, String description, String outputKey, boolean async, boolean optional, AgentCondition activationCondition) static AgentExecutornonAiAgentToExecutor(Object agent, Method agenticMethod) static AgentExecutornonAiAgentToExecutor(Object agent, Method agenticMethod, AgentHelpers helpers) Creates the executor of the non-AI agent implemented by the given method of the given object, with the given helpers: the activation condition and the listener of the agent can be static methods of the agent type or instance methods of its helper objects, and the parameters of the agent method can be provided by aSupplierParameterResolver.static Stringstatic Class<?> static AgentInvocationArgumentsuntypedAgentInvocationArguments(AgenticScope agenticScope) Builds the arguments for an untyped agent, which receives the wholeAgenticScopestate as a singleMap.static MethodvalidateAgentClass(Class<?> agentServiceClass) static MethodvalidateAgentClass(Class<?> agentServiceClass, boolean failOnMissingAnnotation) static MethodvalidateAgentClass(Class<?> agentServiceClass, boolean failOnMissingAnnotation, Class<? extends Annotation> patternAnnotation) Validates that the given agent type declares a single agent method, and returns it: a method annotated with@Agentor with the given pattern annotation, declared by the type, its superclasses or its interfaces.
-
Field Details
-
MEMORY_ID_ARG_NAME
- See Also:
-
AGENTIC_SCOPE_ARG_NAME
- See Also:
-
LOOP_COUNTER_ARG_NAME
- See Also:
-
INVOCATION_PARAMETERS_ARG_NAME
- See Also:
-
-
Method Details
-
outputKey
-
keyDefaultValue
-
keyName
-
agentsToExecutors
-
agentToExecutor
-
humanInTheLoopExecutor
public static AgentExecutor humanInTheLoopExecutor(Method method, Object target, AgentHelpers helpers) Creates the executor of the human-in-the-loop agent implemented by the given method, a static method or an instance method of the given target, that is also one of the helper objects of the agent. -
nonAiAgentToExecutor
-
nonAiAgentToExecutor
public static AgentExecutor nonAiAgentToExecutor(Object agent, Method agenticMethod, AgentHelpers helpers) Creates the executor of the non-AI agent implemented by the given method of the given object, with the given helpers: the activation condition and the listener of the agent can be static methods of the agent type or instance methods of its helper objects, and the parameters of the agent method can be provided by aSupplierParameterResolver. -
nonAiAgentInvoker
public static AgentInvoker nonAiAgentInvoker(Method agenticMethod, String name, String description, String outputKey, boolean async) -
nonAiAgentInvoker
public static AgentInvoker nonAiAgentInvoker(Method agenticMethod, String name, String description, String outputKey, boolean async, boolean optional, AgentCondition activationCondition) -
nonAiAgentInvoker
public static AgentInvoker nonAiAgentInvoker(ResolvedParameters parameters, String name, String description, String outputKey, boolean async, boolean optional, AgentCondition activationCondition, AgentListener listener) Creates the invoker of a non-AI agent method: its parameters provided by aSupplierParameterResolverare not agent arguments, and are resolved at each invocation. The given listener,nullwhen the agent has none, is notified of its invocations. -
agentToExecutor
-
getAnnotatedMethodOnClass
public static Optional<Method> getAnnotatedMethodOnClass(Class<?> clazz, Class<? extends Annotation> annotation) -
argumentsFromMethod
-
argumentsFromMethod
-
argumentsFromMethod
-
argumentsFromMethod
-
argumentFromParameter
-
untypedAgentInvocationArguments
Builds the arguments for an untyped agent, which receives the wholeAgenticScopestate as a singleMap. The map is a filtered copy rather than the state itself: a copy so that the recordedAgentInvocation.input()keeps the state as it was at invocation time instead of following later writes, and filtered so that values which cannot be serialized never reach the agent or the persisted invocation. -
agentInvocationArguments
public static AgentInvocationArguments agentInvocationArguments(AgenticScope agenticScope, Method method) throws MissingArgumentException - Throws:
MissingArgumentException
-
agentInvocationArguments
public static AgentInvocationArguments agentInvocationArguments(AgenticScope agenticScope, List<AgentArgument> agentArguments) throws MissingArgumentException - Throws:
MissingArgumentException
-
agentInvocationArguments
public static AgentInvocationArguments agentInvocationArguments(AgenticScope agenticScope, List<AgentArgument> agentArguments, Map<String, Object> additionalArgs) throws MissingArgumentException- Throws:
MissingArgumentException
-
agentInvocationArguments
public static AgentInvocationArguments agentInvocationArguments(AgenticScope agenticScope, List<AgentArgument> agentArguments, Map<String, Object> additionalArgs, boolean writeConvertedValues) throws MissingArgumentExceptionResolves the arguments from theAgenticScope, converting each value to the type of its argument. WhenwriteConvertedValuesisfalsethe converted values are not written back to the scope, for functions that must leave the scope unchanged, like activation conditions.- Throws:
MissingArgumentException
-
validateAgentClass
-
validateAgentClass
-
validateAgentClass
public static Method validateAgentClass(Class<?> agentServiceClass, boolean failOnMissingAnnotation, Class<? extends Annotation> patternAnnotation) Validates that the given agent type declares a single agent method, and returns it: a method annotated with@Agentor with the given pattern annotation, declared by the type, its superclasses or its interfaces. The method is found also when the type overrides it without the annotation, as a proxy generated by a container does, and is then invoked through the override. -
buildAgent
-
agenticSystemDataTypes
-
rawType
-