Interface AgentNode

All Superinterfaces:
AgentObjectFetcher, com.rpl.agentorama.impl.IFetchAgentClient

public interface AgentNode extends 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 Details

    • emit

      void emit(String node, Object... args)
      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 node
      args - arguments to pass to the target node
    • result

      void result(Object arg)
      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

      <T extends Store> T getStore(String name)
      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

      void streamChunk(Object chunk)
      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

      String getHumanInput(String prompt)
      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

      Map<String,Object> getMetadata()
      Gets metadata associated with this agent execution.
      Returns:
      map of metadata key-value pairs