pub struct AgentGraphBuilder { /* private fields */ }Expand description
Builder for AgentGraph.
Implementations§
Source§impl AgentGraphBuilder
impl AgentGraphBuilder
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Set the graph name (used in streaming events and debugging).
Sourcepub fn add_node(self, name: impl Into<String>, node: Box<dyn Node>) -> Self
pub fn add_node(self, name: impl Into<String>, node: Box<dyn Node>) -> Self
Add a node to the graph.
Sourcepub fn add_node_with_retry(
self,
name: impl Into<String>,
node: Box<dyn Node>,
retry: RetryPolicy,
) -> Self
pub fn add_node_with_retry( self, name: impl Into<String>, node: Box<dyn Node>, retry: RetryPolicy, ) -> Self
Add a node with a retry policy.
Sourcepub fn add_subgraph(self, name: impl Into<String>, subgraph: AgentGraph) -> Self
pub fn add_subgraph(self, name: impl Into<String>, subgraph: AgentGraph) -> Self
Add a subgraph as a node.
Sourcepub fn add_edge(self, from: impl Into<String>, to: impl Into<String>) -> Self
pub fn add_edge(self, from: impl Into<String>, to: impl Into<String>) -> Self
Add a normal edge (always goes to next node). Multiple edges from the same node create fan-out (parallel execution).
Sourcepub fn add_conditional_edge(
self,
from: impl Into<String>,
router: Box<dyn RoutingFunction>,
) -> Self
pub fn add_conditional_edge( self, from: impl Into<String>, router: Box<dyn RoutingFunction>, ) -> Self
Add a conditional edge (uses router to determine next node).
Sourcepub fn set_entry_point(self, node: impl Into<String>) -> Self
pub fn set_entry_point(self, node: impl Into<String>) -> Self
Set the entry point (sugar for add_edge(START, node)).
Sourcepub fn set_finish_point(self, node: impl Into<String>) -> Self
pub fn set_finish_point(self, node: impl Into<String>) -> Self
Set the finish point (sugar for add_edge(node, END)).
Sourcepub fn with_max_iterations(self, max: usize) -> Self
pub fn with_max_iterations(self, max: usize) -> Self
Set maximum iterations before stopping (prevents infinite loops).
Sourcepub fn with_cycle_detection(self, enable: bool) -> Self
pub fn with_cycle_detection(self, enable: bool) -> Self
Enable or disable cycle detection.
Sourcepub fn with_reducer(
self,
key: impl Into<String>,
reducer: impl Reducer + 'static,
) -> Self
pub fn with_reducer( self, key: impl Into<String>, reducer: impl Reducer + 'static, ) -> Self
Register a state reducer for a key.
Sourcepub fn with_interrupt_before(self, nodes: Vec<String>) -> Self
pub fn with_interrupt_before(self, nodes: Vec<String>) -> Self
Set interrupt-before configuration.
Sourcepub fn with_interrupt_after(self, nodes: Vec<String>) -> Self
pub fn with_interrupt_after(self, nodes: Vec<String>) -> Self
Set interrupt-after configuration.
Sourcepub fn with_checkpointer(
self,
checkpointer: impl CheckpointSaver + 'static,
) -> Self
pub fn with_checkpointer( self, checkpointer: impl CheckpointSaver + 'static, ) -> Self
Set the legacy checkpointer for persistence (superstep-level).
Sourcepub fn with_checkpoint_store(self, store: Arc<dyn CheckpointStore>) -> Self
pub fn with_checkpoint_store(self, store: Arc<dyn CheckpointStore>) -> Self
Set the granular checkpoint store (per-attempt recording).
Sourcepub fn with_event_sink(self, sink: Arc<dyn EventSink>) -> Self
pub fn with_event_sink(self, sink: Arc<dyn EventSink>) -> Self
Set a custom event sink for structured event handling.
Sourcepub fn with_executor(self, executor: Arc<dyn Executor>) -> Self
pub fn with_executor(self, executor: Arc<dyn Executor>) -> Self
Set a custom executor for node execution.
Sourcepub fn build(self) -> Result<AgentGraph>
pub fn build(self) -> Result<AgentGraph>
Build the graph.