Annotation Interface ParallelMultiInstanceAgent
Marks a method as a definition of a parallel multi-instance agent, used to orchestrate the agentic workflow
by creating multiple instances of the same sub-agent, one for each item in a collection read from the agentic scope.
Example:
public interface BatchProcessorAgent {
@ParallelMultiInstanceAgent( outputKey = "results",
subAgent = ItemProcessor.class,
inputKey = "items" )
List<Result> process(@V("items") List<Item> items);
}
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionKey referencing a collection in the agentic scope.Class<?> The sub-agent class that will be instantiated for each item in the collection. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionDescription of the agent.Name of the agent.Key of the output variable that will be used to store the result of the agent's invocation.Strongly typed key of the output variable that will be used to store the result of the agent's invocation.
-
Element Details
-
name
String nameName of the agent. If not provided, method name will be used.- Returns:
- name of the agent.
- Default:
""
-
description
String descriptionDescription of the agent. It should be clear and descriptive to allow language model to understand the agent's purpose and its intended use.- Returns:
- description of the agent.
- Default:
""
-
outputKey
String outputKeyKey of the output variable that will be used to store the result of the agent's invocation.- Returns:
- name of the output variable.
- Default:
""
-
typedOutputKey
Strongly typed key of the output variable that will be used to store the result of the agent's invocation. It enforces type safety when retrieving the output from the agent's state and can be used in alternative to theoutputKey()attribute. Note that only one of those two attributes can be used at a time.- Returns:
- class representing the typed output variable.
- Default:
dev.langchain4j.agentic.Agent.NoTypedKey.class
-
subAgent
Class<?> subAgentThe sub-agent class that will be instantiated for each item in the collection.- Returns:
- the sub-agent class.
-
itemsProvider
String itemsProviderKey referencing a collection in the agentic scope. For each item in this collection, an instance of the sub-agent will be created and executed in parallel.- Returns:
- the key of the input collection.
-