Package com.rpl.agentorama
Interface AgentNode
- All Superinterfaces:
AgentObjectFetcher,com.rpl.agentorama.impl.IFetchAgentClient
Interface for agent node functions to interact with the agent execution environment.
Agent nodes are the computational units within an agent graph. This interface
provides access to agent objects, stores, streaming, recording trace information, and other execution capabilities.
Example:
topology.newAgent("myAgent")
.node("start", "process", (AgentNode agentNode, String input) -> {
ChatModel model = agentNode.getAgentObject("openai-model");
KeyValueStore<String, Integer> store = agentNode.getStore("$$myStore");
store.put("key", 42);
agentNode.emit("process", "Hello " + input);
})
.node("process", null, (AgentNode agentNode, String input) -> {
agentNode.result("Processing: " + input);
});
-
Method Summary
Modifier and TypeMethodDescriptionvoidEmits data to another node in the agent graph.com.rpl.rama.DepotGets a depot client within a node.getHumanInput(String prompt) Requests human input during agent execution.Gets metadata associated with this agent execution.getMirrorAgentClient(String moduleName, String agentName) com.rpl.rama.DepotgetMirrorDepot(String moduleName, String name) Gets a depot instance from another module.<T> com.rpl.rama.QueryTopologyClient<T> getMirrorQueryTopologyClient(String moduleName, String name) Gets a query topology client from another module.<T extends Store>
TgetMirrorStore(String moduleName, String name) Gets a store instance from another module.<T> com.rpl.rama.QueryTopologyClient<T> getQueryTopologyClient(String name) Gets a query topology client for invoking queries within a node.<T extends Store>
TGets a store by name for persistent data access.voidrecordNestedOp(NestedOpType nestedOpType, long startTimeMillis, long finishTimeMillis, Map<String, Object> info) Records a nested operation for tracing and analytics.voidSets the final result of the agent execution.voidstreamChunk(Object chunk) Streams a chunk of data to clients.Methods inherited from interface com.rpl.agentorama.AgentObjectFetcher
getAgentObjectMethods inherited from interface com.rpl.agentorama.impl.IFetchAgentClient
getAgentClient
-
Method Details
-
emit
Emits data to another node in the agent graph. The target node must be declared in the outputNodesSpec when creating the agent.- Parameters:
node- the name of the target nodeargs- arguments to pass to the target node
-
result
Sets the final result of the agent execution. This is a first-one wins situation: if multiple nodes return results in parallel, only the first one will be the agent result and others will be dropped.- Parameters:
arg- the final result value
-
getMirrorAgentClient
-
getStore
Gets a store by name for persistent data access. Store names must start with "$$". Stores are declared in the agent topology using: -AgentTopology.declareKeyValueStore(String, Class, Class)for simple key-value storage -AgentTopology.declareDocumentStore(String, Class, Object...)for schema-flexible nested data -AgentTopology.declarePStateStore(String, Class)for direct Rama PState access- Parameters:
name- the name of the store (must start with "$$")- Returns:
- the store instance
-
getMirrorStore
Gets a store instance from another module. Stores provide distributed, persistent, replicated storage. Mirror stores are read-only.- Parameters:
moduleName- the module where the store existsname- the name of the store (declared with declare*Store functions in the target module)- Returns:
- the store instance with API methods (get, put, etc.)
-
getDepot
Gets a depot client within a node. Depots are Rama's append-only logs that can be consumed by any number of topologies.- Parameters:
name- the name of the depot (declared in the module)- Returns:
- Depot instance for appending data
-
getMirrorDepot
Gets a depot instance from another module. Depots are Rama's append-only logs that can be consumed by any number of topologies.- Parameters:
moduleName- the module where the depot existsname- the name of the depot (declared in the target module)- Returns:
- Depot instance for appending data
-
getQueryTopologyClient
Gets a query topology client for invoking queries within a node.- Parameters:
name- the name of the query topology- Returns:
- QueryTopologyClient instance
-
getMirrorQueryTopologyClient
<T> com.rpl.rama.QueryTopologyClient<T> getMirrorQueryTopologyClient(String moduleName, String name) Gets a query topology client from another module.- Parameters:
moduleName- the module where the query topology existsname- the name of the query topology- Returns:
- QueryTopologyClient instance
-
streamChunk
Streams a chunk of data to clients.- Parameters:
chunk- the data chunk to stream
-
recordNestedOp
void recordNestedOp(NestedOpType nestedOpType, long startTimeMillis, long finishTimeMillis, Map<String, Object> info) Records a nested operation for tracing and analytics. Nested operations track internal operations like model calls, database access, and tool calls within an agent execution. The info map provides type-specific metadata for the operation. Special info map usage for certain operation types that gets incorporated into analytics: - model call: "inputTokenCount", "outputTokenCount", "totalTokenCount", "failure" (exception string for failures) -
getHumanInput
Requests human input during agent execution. This method blocks until human input is provided. The agent execution will pause until the input is received. The agent will remain in a waiting state unti the human provides a response through the client API or web UI. Since nodes run on virtual threads, this is efficient.- Parameters:
prompt- the prompt to show to the human- Returns:
- the human's response
-
getMetadata
Gets metadata associated with this agent execution.- Returns:
- map of metadata key-value pairs
-