Skip to main content

AgentGraph

Struct AgentGraph 

Source
pub struct AgentGraph { /* private fields */ }
Expand description

The agent graph — an orchestrator that owns control-flow and delegates node work to the Payload layer.

Implementations§

Source§

impl AgentGraph

Execution-related methods on AgentGraph.

Source

pub async fn execute( &self, start_node: &str, state: AgentState, ) -> Result<AgentState>

Execute the graph starting from a specific node.

Source

pub async fn execute_with_summary( &self, start_node: &str, state: AgentState, config: GraphConfig, ) -> (Result<AgentState>, RunSummary)

Execute the graph and return a structured run summary alongside the result.

Source

pub async fn execute_with_config( &self, start_node: &str, state: AgentState, config: GraphConfig, ) -> Result<AgentState>

Execute the graph with a runtime config.

Source

pub async fn execute_with_interrupt( &self, start_node: &str, state: AgentState, config: GraphConfig, ) -> ExecutionResult

Execute the graph with interrupt support.

Source

pub fn execute_cancellable( self: Arc<Self>, start_node: &str, state: AgentState, config: GraphConfig, ) -> (JoinHandle<Result<AgentState>>, Arc<AtomicBool>)

Execute with cancellation support using an Arc-wrapped graph.

Source

pub fn stream( self: Arc<Self>, start_node: &str, state: AgentState, config: GraphConfig, ) -> (JoinHandle<Result<AgentState>>, Receiver<StreamEvent>)

Execute with streaming using Arc-wrapped graph. Returns a join handle for the result and a receiver for events.

Source§

impl AgentGraph

Source

pub fn builder() -> AgentGraphBuilder

Create a new graph builder.

Source

pub async fn resume( &self, state: AgentState, config: GraphConfig, checkpoint: InterruptCheckpoint, ) -> Result<AgentState>

Resume execution from an interrupt checkpoint.

Validates that the graph topology hasn’t changed since the checkpoint was taken. Returns CheckpointMismatch if the graph hash differs. Use Self::resume_force to skip this check.

Source

pub async fn resume_force( &self, state: AgentState, config: GraphConfig, checkpoint: InterruptCheckpoint, ) -> Result<AgentState>

Resume execution from an interrupt checkpoint without validating graph topology.

Source

pub async fn get_state( &self, config: &GraphConfig, ) -> Result<Option<AgentState>>

Get current state from checkpointer.

Source

pub async fn get_state_history( &self, config: &GraphConfig, ) -> Result<Vec<Checkpoint>>

Get checkpoint history for a thread.

Source

pub async fn update_state( &self, config: &GraphConfig, updates: HashMap<String, Value>, ) -> Result<()>

Update state in the checkpointer (time travel).

Source

pub fn to_mermaid(&self) -> String

Generate a Mermaid diagram of the graph structure.

Source

pub fn name(&self) -> Option<&str>

Get the graph name.

Source

pub fn node_names(&self) -> Vec<&String>

Get the node names.

Source

pub fn edge_map(&self) -> &HashMap<String, Vec<EdgeType>>

Get the edge map for inspection.

Source

pub fn compute_graph_hash(&self) -> String

Compute a stable hash of the graph’s topology (node names + edges).

Used to detect graph-definition drift when resuming from a checkpoint. Two graphs with the same nodes and edges produce the same hash.

Trait Implementations§

Source§

impl Debug for AgentGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Node for AgentGraph

Source§

fn execute<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, state: &'life1 AgentState, config: &'life2 GraphConfig, ) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Execute this node
Source§

fn name(&self) -> Option<&str>

Optional: Get a name for this node (for debugging)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more