pub struct NodeOutput {
pub updates: HashMap<String, Value>,
pub interrupt: Option<Interrupt>,
pub events: Vec<StreamEvent>,
pub goto: Option<Vec<String>>,
pub goto_parent: Option<Vec<String>>,
}Expand description
Output from a node execution
Fields§
§updates: HashMap<String, Value>State updates to apply
interrupt: Option<Interrupt>Optional interrupt request
events: Vec<StreamEvent>Custom stream events
goto: Option<Vec<String>>Nodes to run next, replacing this node’s declared outgoing edges.
goto_parent: Option<Vec<String>>Nodes of the parent graph to run next, when this graph is a subgraph.
A node deep in a nested graph can end its own graph and hand control to a node of the graph that holds it.
Implementations§
Source§impl NodeOutput
impl NodeOutput
Sourcepub fn with_goto_parent<I, S>(self, targets: I) -> Self
pub fn with_goto_parent<I, S>(self, targets: I) -> Self
Names the nodes to run next, replacing this node’s declared edges.
A conditional edge fixes its targets when the graph is built. This does
not: a node reads state and names any node in the graph, including one it
has no edge to. Naming END stops the branch.
The declared edges from this node do not also fire. Setting no goto leaves the declared edges in charge, which is the default.
§Example
use adk_graph::node::NodeOutput;
use serde_json::json;
// Write state and choose the next node in one step.
let output = NodeOutput::new()
.with_update("risk", json!("high"))
.with_goto(["escalate"]);
assert_eq!(output.goto.as_deref(), Some(&["escalate".to_string()][..]));Names nodes of the parent graph to run next.
Only meaningful inside a SubgraphNode.
The subgraph finishes, its output channels are projected out as usual, and
the parent continues at the named nodes rather than following the
subgraph node’s own edges. This is the counterpart to LangGraph’s
Command(goto=..., graph=Command.PARENT).
A name the parent does not hold fails the run with
GraphError::UnknownRouteTarget,
checked by the parent, which is the only side that knows its own nodes.
§Example
use adk_graph::node::NodeOutput;
use serde_json::json;
// Inside a subgraph: give up, and let the parent's escalation path run.
let output = NodeOutput::new()
.with_update("reason", json!("no confident answer"))
.with_goto_parent(["escalate"]);
assert_eq!(output.goto_parent.as_deref(), Some(&["escalate".to_string()][..]));pub fn with_goto<I, S>(self, targets: I) -> Self
Sourcepub fn with_update(self, key: &str, value: impl Into<Value>) -> Self
pub fn with_update(self, key: &str, value: impl Into<Value>) -> Self
Add a state update
Sourcepub fn with_updates(self, updates: HashMap<String, Value>) -> Self
pub fn with_updates(self, updates: HashMap<String, Value>) -> Self
Add multiple state updates
Sourcepub fn with_interrupt(self, interrupt: Interrupt) -> Self
pub fn with_interrupt(self, interrupt: Interrupt) -> Self
Set an interrupt
Sourcepub fn with_event(self, event: StreamEvent) -> Self
pub fn with_event(self, event: StreamEvent) -> Self
Add a custom stream event
Sourcepub fn interrupt_with_data(message: &str, data: Value) -> Self
pub fn interrupt_with_data(message: &str, data: Value) -> Self
Create output that triggers a dynamic interrupt with data