Class FunctionNode.Builder<I,O>
java.lang.Object
com.google.adk.workflow.FunctionNode.Builder<I,O>
- Enclosing class:
FunctionNode<I,O>
Fluent builder for
FunctionNode. Any property left unset falls back to the default of
the matching Node property, except that rerunOnResume defaults to true for a
node that requires confirmation; name and body are required.-
Method Summary
Modifier and TypeMethodDescriptionSets the function the node runs on each input.build()Builds the node.config(NodeConfig config) Sets the node's retry policy and execution timeout.description(String description) Sets what the node does, for humans and for a model that may call it.inputSchema(@Nullable com.google.genai.types.Schema inputSchema) Sets the schema that describes the node's input, in place of one inferred from its type.Sets the node's name, unique within its graph.outputSchema(@Nullable com.google.genai.types.Schema outputSchema) Sets the schema that describes the node's output, in place of one inferred from its type.requireConfirmation(boolean requireConfirmation) Sets whether each run first asks the user to approve it; either overload replaces the other.requireConfirmation(ConfirmationPredicate<? super I> predicate) Sets a predicate that decides for each input whether a run asks the user to approve it, as thebooleanoverload does for every input.rerunOnResume(boolean rerunOnResume) Sets whether a resume runs the node again rather than using the resuming answer.scheduler(@Nullable io.reactivex.rxjava3.core.Scheduler scheduler) Sets the scheduler that decodes the input and runs the confirmation predicate and the body, ornull(the default) for theRunner's scheduler.stateSchema(@Nullable com.google.genai.types.Schema stateSchema) Sets the state keys the node uses, which child nodes inherit unless they declare their own.waitForOutput(boolean waitForOutput) Sets whether the node stays re-triggerable until it produces an output or a route.
-
Method Details
-
name
Sets the node's name, unique within its graph. Required. -
description
Sets what the node does, for humans and for a model that may call it. -
rerunOnResume
Sets whether a resume runs the node again rather than using the resuming answer. Unset, it is true for a node that requires confirmation and false otherwise. A body that runs child nodes throughContext.runNode(Node, Object, RunNodeConfig)requirestrue: on resume the body runs again from the start, a child that asked resumes with its answer, and the other children resume asRunNodeConfig.runId()describes. -
waitForOutput
Sets whether the node stays re-triggerable until it produces an output or a route. -
config
Sets the node's retry policy and execution timeout. -
inputSchema
@CanIgnoreReturnValue public FunctionNode.Builder<I,O> inputSchema(@Nullable com.google.genai.types.Schema inputSchema) Sets the schema that describes the node's input, in place of one inferred from its type. On aContentport, the schema describes the message's text. -
outputSchema
@CanIgnoreReturnValue public FunctionNode.Builder<I,O> outputSchema(@Nullable com.google.genai.types.Schema outputSchema) Sets the schema that describes the node's output, in place of one inferred from its type. -
stateSchema
@CanIgnoreReturnValue public FunctionNode.Builder<I,O> stateSchema(@Nullable com.google.genai.types.Schema stateSchema) Sets the state keys the node uses, which child nodes inherit unless they declare their own. -
requireConfirmation
@CanIgnoreReturnValue public FunctionNode.Builder<I,O> requireConfirmation(boolean requireConfirmation) Sets whether each run first asks the user to approve it; either overload replaces the other. Such a node reruns on resume, so a body that asks for input reads its answer fromContext.resumeInputs()before asking. An approved run reads the user's decision fromContext.toolConfirmation(), and a rejected run skips the body and outputs{"error": "This tool call is rejected."}whatever the output type, so a successor that must handle a rejection takesObject. -
requireConfirmation
@CanIgnoreReturnValue public FunctionNode.Builder<I,O> requireConfirmation(ConfirmationPredicate<? super I> predicate) Sets a predicate that decides for each input whether a run asks the user to approve it, as thebooleanoverload does for every input. Once the node has asked, the answer decides. -
body
-
scheduler
@CanIgnoreReturnValue public FunctionNode.Builder<I,O> scheduler(@Nullable io.reactivex.rxjava3.core.Scheduler scheduler) Sets the scheduler that decodes the input and runs the confirmation predicate and the body, ornull(the default) for theRunner's scheduler. A body that callsContext.emit(Event)cannot run inline, and bodies that wait for one another need a thread each, so a small fixed-size scheduler can hang the run; ADK Kotlin instead defaults toDispatchers.IO, which gives each waiting body a thread. Once that work ends, even when a confirmation skips the body, the outcome is handed back on theRunner's scheduler, unless that scheduler equals this one (twoSchedulers.fromof one executor do not) or runs work inline, in which case it stays on this thread. The scheduler must accept this work: a rejected body leaves the run waiting, as aRunnerscheduler that rejects work does. -
build
Builds the node.- Throws:
IllegalStateException- if the name or the body is not setWorkflowConfigurationException- if the node requires confirmation butrerunOnResumeis set to false
-