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.
    static Object
    checkStateValue(@Nullable com.google.genai.types.Schema stateSchema, String key, Object value)
    Returns value checked against stateSchema for key, in the form a stored session reads back, as for node outputs; public only for Context.
    boolean
    Sends event, which needs an ID, on behalf of Context.emit(Event); false if no body runs.
    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 isolation scope this run's events carry unless they set their own, or empty when unscoped.
    Returns the node this run belongs to.
    Returns the path of this run: name@runId segments joined by /, starting at the outermost node.
    boolean
    Returns whether another run at path, under the same root, started in this turn and has not finished, such as a delegator whose task handed off to this run.
    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 for a run at the top of the invocation: a root node or a handoff target that runs beside it.
    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.
    Optional<com.google.genai.types.Schema>
    Returns the state schema in force for this run: its node's own or the nearest ancestor's.

    Methods inherited from class 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 for a run at the top of the invocation: a root node or a handoff target that runs beside it.
    • isolationScope

      public Optional<String> isolationScope()
      Returns the isolation scope this run's events carry unless they set their own, or empty when unscoped. A run takes its parent's scope unless it was started with its own.
    • 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.
    • stateSchema

      public Optional<com.google.genai.types.Schema> stateSchema()
      Returns the state schema in force for this run: its node's own or the nearest ancestor's.
    • checkStateValue

      public static Object checkStateValue(@Nullable com.google.genai.types.Schema stateSchema, String key, Object value)
      Returns value checked against stateSchema for key, in the form a stored session reads back, as for node outputs; public only for Context. Keys with a colon, State.REMOVED and writes under no schema pass unchecked.
      Throws:
      StateSchemaException - if the schema does not declare key, or if the value does not match or converts to null
    • emitFromBody

      public boolean emitFromBody(Event event)
      Sends event, which needs an ID, on behalf of Context.emit(Event); false if no body runs.
    • otherRunInProgress

      public boolean otherRunInProgress(String path)
      Returns whether another run at path, under the same root, started in this turn and has not finished, such as a delegator whose task handed off to this run.