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.getHumanInput(String prompt) Requests human input during agent execution.Gets metadata associated with this agent execution.<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
-
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
-
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
-