Class NodeExecutionState

java.lang.Object
com.google.adk.workflow.NodeExecutionState

@Experimental public final class NodeExecutionState extends Object
The state of one workflow node run, held by the run's Context. Only the workflow runtime creates it and updates the bookkeeping that records which results an event has carried. Its output, interrupt IDs and child run IDs are safe to update from several threads, since children that a node runs itself may start and finish on other threads.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of this attempt at running the node, counting from 1.
    Returns the author of the events this run emits, or empty to use the node's name.
    void
    eventAuthor(String eventAuthor)
    Sets the author of the events this run emits.
    com.google.common.collect.ImmutableSet<String>
    Returns the IDs of the long-running tool calls the node is waiting on.
    Returns the node this run belongs to.
    Returns the path of this run: name@runId segments joined by /, starting at the outermost node.
    Returns the node's output, which is the output of its useAsOutput child once that child emits one, or empty if it has none.
    Returns the context of the node that ran this node, or empty if this is a root node.
    void
    Records the node's output, which an event carries when the node finishes unless an earlier event already carried it.
    Map<String,@Nullable Object>
    Returns the user's answers to the requests for input and long-running calls that this node or its descendants raised in an earlier turn, keyed by interrupt ID.
    Returns the ID of this run among the node's runs, counting from "1".
    Optional<com.google.common.collect.ImmutableList<Route>>
    Returns the routes the node selected, which decide the outgoing edges to follow, or empty if it made no routing decision.
    void
    selectRoutes(List<? extends Route> routes)
    Selects the node's routes, replacing any earlier selection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • node

      public Node node()
      Returns the node this run belongs to.
    • nodePath

      public String nodePath()
      Returns the path of this run: name@runId segments joined by /, starting at the outermost node.
    • runId

      public String runId()
      Returns the ID of this run among the node's runs, counting from "1".
    • attemptCount

      public int attemptCount()
      Returns the number of this attempt at running the node, counting from 1.
    • parent

      public Optional<Context> parent()
      Returns the context of the node that ran this node, or empty if this is a root node.
    • eventAuthor

      public String eventAuthor()
      Returns the author of the events this run emits, or empty to use the node's name. A run under a parent starts with the parent's author.
    • eventAuthor

      public void eventAuthor(String eventAuthor)
      Sets the author of the events this run emits.
    • output

      public Optional<Object> output()
      Returns the node's output, which is the output of its useAsOutput child once that child emits one, or empty if it has none.
    • produceOutput

      public void produceOutput(Object output)
      Records the node's output, which an event carries when the node finishes unless an earlier event already carried it. A node produces at most one output. Once the node delegates its output to a useAsOutput child, an output it produces itself is dropped, as in Python ADK.
      Throws:
      IllegalStateException - if the node already produced an output of its own, even one that was dropped
    • selectedRoutes

      public Optional<com.google.common.collect.ImmutableList<Route>> selectedRoutes()
      Returns the routes the node selected, which decide the outgoing edges to follow, or empty if it made no routing decision. An empty list is a decision that selects no route.
    • selectRoutes

      public void selectRoutes(List<? extends Route> routes)
      Selects the node's routes, replacing any earlier selection. An event carries them when the node finishes unless an earlier event already carried them.
    • interruptIds

      public com.google.common.collect.ImmutableSet<String> interruptIds()
      Returns the IDs of the long-running tool calls the node is waiting on.
    • resumeInputs

      public Map<String,@Nullable Object> resumeInputs()
      Returns the user's answers to the requests for input and long-running calls that this node or its descendants raised in an earlier turn, keyed by interrupt ID. A null answer has a null value in the map. The map is empty unless the node reruns on resume.