Package com.rpl.agentorama
Interface AgentGraph
public interface AgentGraph
Builder interface for defining agent execution graphs.
AgentGraph provides a fluent API for building agent execution graphs with nodes,
aggregation subgraphs, and control flow. Each agent is defined as a directed
graph where nodes represent computational units and edges represent data flow.
Example usage:
topology.newAgent("my-agent")
.node("start", "process", (AgentNode agentNode, String input) -> {
agentNode.emit("process", "Hello " + input);
})
.node("process", null, (AgentNode agentNode, String data) -> {
agentNode.result("Processed: " + data);
});
-
Method Summary
Modifier and TypeMethodDescription<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, com.rpl.agentorama.impl.BuiltInAgg agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a built-in aggregator.<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, MultiAgg.Impl agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a multi-aggregator.<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaAccumulatorAgg agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a Rama accumulator aggregator.<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaCombinerAgg agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a Rama combiner aggregator.aggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction1<AgentNode, Object> impl) Adds an aggregation start node with zero arguments that scopes aggregation within a subgraph.<T0> AgentGraphaggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction2<AgentNode, T0, Object> impl) Adds an aggregation start node with one argument that scopes aggregation within a subgraph.<T0,T1> AgentGraph aggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction3<AgentNode, T0, T1, Object> impl) Adds an aggregation start node with two arguments that scopes aggregation within a subgraph.<T0,T1, T2>
AgentGraphaggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction4<AgentNode, T0, T1, T2, Object> impl) Adds an aggregation start node with three arguments that scopes aggregation within a subgraph.<T0,T1, T2, T3>
AgentGraphaggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction5<AgentNode, T0, T1, T2, T3, Object> impl) Adds an aggregation start node with four arguments that scopes aggregation within a subgraph.<T0,T1, T2, T3, T4>
AgentGraphaggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction6<AgentNode, T0, T1, T2, T3, T4, Object> impl) Adds an aggregation start node with five arguments that scopes aggregation within a subgraph.<T0,T1, T2, T3, T4, T5>
AgentGraphaggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction7<AgentNode, T0, T1, T2, T3, T4, T5, Object> impl) Adds an aggregation start node with six arguments that scopes aggregation within a subgraph.<T0,T1, T2, T3, T4, T5, T6>
AgentGraphaggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction8<AgentNode, T0, T1, T2, T3, T4, T5, T6, Object> impl) Adds an aggregation start node with seven arguments that scopes aggregation within a subgraph.node(String name, Object outputNodesSpec, RamaVoidFunction1<AgentNode> impl) Adds a node to the agent graph with zero arguments.<T0> AgentGraphnode(String name, Object outputNodesSpec, RamaVoidFunction2<AgentNode, T0> impl) Adds a node to the agent graph with one argument.<T0,T1> AgentGraph node(String name, Object outputNodesSpec, RamaVoidFunction3<AgentNode, T0, T1> impl) Adds a node to the agent graph with two arguments.<T0,T1, T2>
AgentGraphnode(String name, Object outputNodesSpec, RamaVoidFunction4<AgentNode, T0, T1, T2> impl) Adds a node to the agent graph with three arguments.<T0,T1, T2, T3>
AgentGraphnode(String name, Object outputNodesSpec, RamaVoidFunction5<AgentNode, T0, T1, T2, T3> impl) Adds a node to the agent graph with four arguments.<T0,T1, T2, T3, T4>
AgentGraphnode(String name, Object outputNodesSpec, RamaVoidFunction6<AgentNode, T0, T1, T2, T3, T4> impl) Adds a node to the agent graph with five arguments.<T0,T1, T2, T3, T4, T5>
AgentGraphnode(String name, Object outputNodesSpec, RamaVoidFunction7<AgentNode, T0, T1, T2, T3, T4, T5> impl) Adds a node to the agent graph with six arguments.<T0,T1, T2, T3, T4, T5, T6>
AgentGraphnode(String name, Object outputNodesSpec, RamaVoidFunction8<AgentNode, T0, T1, T2, T3, T4, T5, T6> impl) Adds a node to the agent graph with seven arguments.setUpdateMode(UpdateMode mode) Sets the update mode for this agent graph.
-
Method Details
-
setUpdateMode
Sets the update mode for this agent graph. Controls how in-flight agent executions are handled after the module is updated.- Parameters:
mode- the update mode (CONTINUE, RESTART, or DROP)- Returns:
- this agent graph for method chaining
-
node
Adds a node to the agent graph with zero arguments. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
node
Adds a node to the agent graph with one argument. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
node
<T0,T1> AgentGraph node(String name, Object outputNodesSpec, RamaVoidFunction3<AgentNode, T0, T1> impl) Adds a node to the agent graph with two arguments. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
node
<T0,T1, AgentGraph nodeT2> (String name, Object outputNodesSpec, RamaVoidFunction4<AgentNode, T0, T1, T2> impl) Adds a node to the agent graph with three arguments. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
node
<T0,T1, AgentGraph nodeT2, T3> (String name, Object outputNodesSpec, RamaVoidFunction5<AgentNode, T0, T1, T2, T3> impl) Adds a node to the agent graph with four arguments. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
node
<T0,T1, AgentGraph nodeT2, T3, T4> (String name, Object outputNodesSpec, RamaVoidFunction6<AgentNode, T0, T1, T2, T3, T4> impl) Adds a node to the agent graph with five arguments. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
node
<T0,T1, AgentGraph nodeT2, T3, T4, T5> (String name, Object outputNodesSpec, RamaVoidFunction7<AgentNode, T0, T1, T2, T3, T4, T5> impl) Adds a node to the agent graph with six arguments. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
node
<T0,T1, AgentGraph nodeT2, T3, T4, T5, T6> (String name, Object outputNodesSpec, RamaVoidFunction8<AgentNode, T0, T1, T2, T3, T4, T5, T6> impl) Adds a node to the agent graph with seven arguments. Nodes are the fundamental computation units in agent graphs. Each node receives data from upstream nodes and can emit data to downstream nodes or return a final result.- Parameters:
name- the name of the node (must be unique within the agent)outputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic- Returns:
- this agent graph for method chaining
-
aggStartNode
AgentGraph aggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction1<AgentNode, Object> impl) Adds an aggregation start node with zero arguments that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggStartNode
<T0> AgentGraph aggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction2<AgentNode, T0, Object> impl) Adds an aggregation start node with one argument that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggStartNode
<T0,T1> AgentGraph aggStartNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction3<AgentNode, T0, T1, Object> impl) Adds an aggregation start node with two arguments that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggStartNode
<T0,T1, AgentGraph aggStartNodeT2> (String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction4<AgentNode, T0, T1, T2, Object> impl) Adds an aggregation start node with three arguments that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggStartNode
<T0,T1, AgentGraph aggStartNodeT2, T3> (String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction5<AgentNode, T0, T1, T2, T3, Object> impl) Adds an aggregation start node with four arguments that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggStartNode
<T0,T1, AgentGraph aggStartNodeT2, T3, T4> (String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction6<AgentNode, T0, T1, T2, T3, T4, Object> impl) Adds an aggregation start node with five arguments that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggStartNode
<T0,T1, AgentGraph aggStartNodeT2, T3, T4, T5> (String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction7<AgentNode, T0, T1, T2, T3, T4, T5, Object> impl) Adds an aggregation start node with six arguments that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggStartNode
<T0,T1, AgentGraph aggStartNodeT2, T3, T4, T5, T6> (String name, Object outputNodesSpec, com.rpl.rama.ops.RamaFunction8<AgentNode, T0, T1, T2, T3, T4, T5, T6, Object> impl) Adds an aggregation start node with seven arguments that scopes aggregation within a subgraph. Aggregation start nodes work like regular nodes but define the beginning of an aggregation subgraph. They must have a correspondingaggNode(String, Object, RamaAccumulatorAgg, RamaVoidFunction3)downstream. Within the aggregation subgraph, edges must stay within the subgraph and cannot connect to nodes outside of it. The return value of the node function is passed to the downstream aggregation node as its last argument, allowing propagation of non-aggregated information downstream post-aggregation.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.impl- the function that implements the node logic. Return value is passed to downstream aggregation node as last argument.- Returns:
- this agent graph for method chaining
-
aggNode
<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaAccumulatorAgg agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a Rama accumulator aggregator. Aggregation nodes gather results from parallel processing nodes and combine them using a specified aggregation function. They receive both the collected results and any return value from the aggregation start node.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.agg- the Rama accumulator aggregator for combining resultsimpl- the function that processes the aggregated results. Takes (agentNode, aggregatedValue, aggStartResult) where aggStartResult is the return value from the corresponding aggregation start node- Returns:
- this agent graph for method chaining
-
aggNode
<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, com.rpl.rama.ops.RamaCombinerAgg agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a Rama combiner aggregator. Aggregation nodes gather results from parallel processing nodes and combine them using a specified aggregation function. They receive both the collected results and any return value from the aggregation start node.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.agg- the Rama combiner aggregator for combining resultsimpl- the function that processes the aggregated results. Takes (agentNode, aggregatedValue, aggStartResult) where aggStartResult is the return value from the corresponding aggregation start node- Returns:
- this agent graph for method chaining
-
aggNode
<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, MultiAgg.Impl agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a multi-aggregator. Aggregation nodes gather results from parallel processing nodes and combine them using a specified aggregation function. They receive both the collected results and any return value from the aggregation start node. Multi-aggregators provide dispatch-based aggregation where different values are processed by different aggregation functions based on a dispatch key.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.agg- the multi-aggregator for dispatch-based aggregationimpl- the function that processes the aggregated results. Takes (agentNode, aggregatedValue, aggStartResult) where aggStartResult is the return value from the corresponding aggregation start node- Returns:
- this agent graph for method chaining
-
aggNode
<S,T> AgentGraph aggNode(String name, Object outputNodesSpec, com.rpl.agentorama.impl.BuiltInAgg agg, RamaVoidFunction3<AgentNode, S, T> impl) Adds an aggregation node that collects and combines results using a built-in aggregator. Aggregation nodes gather results from parallel processing nodes and combine them using a specified aggregation function. They receive both the collected results and any return value from the aggregation start node. Built-in aggregators provide common aggregation patterns like sum, count, min, max, etc. SeeBuiltInfor available built-in aggregators.- Parameters:
name- the name of the nodeoutputNodesSpec- target node name(s) for emissions, or null for terminal nodes. Can be a string, array of strings, or null. Calls toAgentNode.emit(String, Object...)inside the node function must target one of these declared nodes.agg- the built-in aggregator for combining resultsimpl- the function that processes the aggregated results. Takes (agentNode, aggregatedValue, aggStartResult) where aggStartResult is the return value from the corresponding aggregation start node- Returns:
- this agent graph for method chaining
-