Class BaseNode
java.lang.Object
com.google.adk.workflow.BaseNode
- All Implemented Interfaces:
Node
- Direct Known Subclasses:
BaseAgent, ClassifierNode, FunctionNode, JoinNode, Workflow
Base class for nodes in a workflow graph. It is meant for the framework's own nodes; to write a
node, implement
Node. Subclasses implement Node.runNode(Context, Object), and the framework turns each
emission into an Event.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a node with every property other than its name and description at its default.protectedBaseNode(String name, String description, boolean rerunOnResume, boolean waitForOutput, NodeConfig config, @Nullable com.google.genai.types.Schema inputSchema, @Nullable com.google.genai.types.Schema outputSchema, @Nullable com.google.genai.types.Schema stateSchema) Creates a node; each parameter sets theNodeproperty of the same name. -
Method Summary
Modifier and TypeMethodDescriptionconfig()Returns the node's retry policy and execution timeout.Returns what the node does, for humans and for a model that may call it.Optional<com.google.genai.types.Schema> Returns the schema the node's input must match.final Stringname()Returns the name that identifies the node within its graph.Optional<com.google.genai.types.Schema> Returns the schema that the node's output value must match.booleanReturnstrueif a resumed node runs again from scratch, rather than completing with the resuming answer as its output.Optional<com.google.genai.types.Schema> Returns the schema of the state keys that the node and its children may write; a child inherits it unless it declares its own.protected voidvalidateOutgoingEdges(Collection<Edge> edges) ThrowsGraphValidationExceptionif this node cannot serve theedgesthat leave it, such as an edge for a route it never emits.booleanReturnstrueif the node stays re-triggerable until it produces an output or a route, instead of completing when its run completes.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Node
requiresAllPredecessors, runNodeModifier and TypeMethodDescriptiondefault booleanReturnstrueif the node runs only once every predecessor has completed, receiving all their outputs keyed by node name, as a fan-in node does.io.reactivex.rxjava3.core.Flowable<?> Runs the node onnodeInput, the output it receives from its predecessors.
-
Constructor Details
-
BaseNode
-
BaseNode
protected BaseNode(String name, String description, boolean rerunOnResume, boolean waitForOutput, NodeConfig config, @Nullable com.google.genai.types.Schema inputSchema, @Nullable com.google.genai.types.Schema outputSchema, @Nullable com.google.genai.types.Schema stateSchema) Creates a node; each parameter sets theNodeproperty of the same name.
-
-
Method Details
-
name
-
description
Description copied from interface:NodeReturns what the node does, for humans and for a model that may call it.- Specified by:
descriptionin interfaceNode
-
rerunOnResume
public boolean rerunOnResume()Description copied from interface:NodeReturnstrueif a resumed node runs again from scratch, rather than completing with the resuming answer as its output.- Specified by:
rerunOnResumein interfaceNode
-
waitForOutput
public boolean waitForOutput()Description copied from interface:NodeReturnstrueif the node stays re-triggerable until it produces an output or a route, instead of completing when its run completes.- Specified by:
waitForOutputin interfaceNode
-
config
Description copied from interface:NodeReturns the node's retry policy and execution timeout. -
inputSchema
Description copied from interface:NodeReturns the schema the node's input must match. An edge into the node fails at build when its source's output schema lists a key or type this one rejects, so an open producer such as a map builds, and aFunctionNodeon aContentport checks the edge against theContentschema. A node that requires all predecessors applies it to each predecessor's output, not the joined map. A run checks a node's schemas only for type,nullable,enum,anyOf,properties,requiredanditems; it ignoresminimum,maximum,pattern, lengths andformat.- Specified by:
inputSchemain interfaceNode
-
outputSchema
Description copied from interface:NodeReturns the schema that the node's output value must match. The content of a message-as-output event is not checked against this schema. A run checks a record, POJO or enum input or output in its JSON form and hands on that form: a map for a record, the name for an enum.- Specified by:
outputSchemain interfaceNode
-
stateSchema
Description copied from interface:NodeReturns the schema of the state keys that the node and its children may write; a child inherits it unless it declares its own. The runtime converts writes throughContext.state()in a node or in a tool node's tool, emitted events' state deltas and tool nodes' deltas to the declared type, throwingStateSchemaExceptionon a mismatch or undeclared key; aFunctionToollets it through, so it fails the node. Keys with a colon and a node's direct writes to its ownContext.eventActions()'s state delta pass unchecked. A stored value reads back in the form a stored session gives: lists and maps unmodifiable, a record as a map, an enum by its name, a small whole number as anInteger.- Specified by:
stateSchemain interfaceNode
-
validateOutgoingEdges
ThrowsGraphValidationExceptionif this node cannot serve theedgesthat leave it, such as an edge for a route it never emits. The default accepts any edges. Building the workflow graph calls it after its own checks.
-