Skip to main content

CompiledGraph

Struct CompiledGraph 

Source
pub struct CompiledGraph<S: StateSchema> { /* private fields */ }
Expand description

CompiledGraph - Ready-to-execute graph

Created from StateGraph.compile(). Handles:

  • State management and updates
  • Edge routing (fixed and conditional)
  • Execution with recursion limits
  • Checkpointing for persistence

Implementations§

Source§

impl<S: StateSchema> CompiledGraph<S>

Source

pub fn with_checkpointer<C: Checkpointer<S> + 'static>( self, checkpointer: C, ) -> Self

Source

pub fn with_recursion_limit(self, limit: usize) -> Self

Source

pub fn with_interrupt_before(self, nodes: Vec<String>) -> Self

Source

pub fn with_interrupt_after(self, nodes: Vec<String>) -> Self

Source

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

Source

pub fn get_edges(&self) -> &[GraphEdge]

Source

pub fn entry_point(&self) -> &str

Source

pub fn recursion_limit(&self) -> usize

Source

pub fn interrupt_before(&self) -> &[String]

Source

pub fn interrupt_after(&self) -> &[String]

Source

pub async fn last_checkpoint_state(&self) -> Option<S>

Get the last checkpoint state (for interrupt recovery)

Source

pub async fn create_resume_execution( &self, interrupted_node: &str, ) -> Option<GraphExecution<S>>

Create a resume execution context (from the last checkpoint) interrupted_node may be “node_name” or “after_node_name”

Source

pub fn submit_task(&self, description: String)

Submit a new task for dynamic planning mid-execution

Source

pub async fn inject_node( &self, name: &str, node: Arc<dyn GraphNode<S>>, ) -> GraphResult<()>

Inject a runtime node directly

Source

pub async fn inject_edge(&self, source: &str, target: &str) -> GraphResult<()>

Inject a runtime edge directly

Source

pub async fn inject_subgraph<SubS: StateSchema + 'static>( &self, name: &str, subgraph: CompiledGraph<SubS>, input_mapper: impl Fn(&S) -> SubS + Send + Sync + 'static, output_mapper: impl Fn(&SubS, &mut S) + Send + Sync + 'static, ) -> GraphResult<()>

Inject a subgraph as a runtime node

Source§

impl<S: StateSchema> CompiledGraph<S>

Source

pub async fn invoke(&self, input: S) -> GraphResult<GraphInvocation<S>>

Source

pub async fn invoke_with_execution( &self, execution: GraphExecution<S>, ) -> GraphResult<GraphInvocation<S>>

Source

pub async fn resume( &self, execution: GraphExecution<S>, ) -> GraphResult<GraphInvocation<S>>

Source

pub async fn invoke_from_node( &self, start_node: String, input: S, ) -> GraphResult<GraphInvocation<S>>

Source§

impl<S: StateSchema> CompiledGraph<S>

Source

pub async fn invoke_parallel( &self, input: S, ) -> GraphResult<ParallelInvocation<S>>

Source

pub async fn invoke_dynamic( &self, input: S, planner: &dyn DynamicPlanner<S>, ) -> GraphResult<GraphInvocation<S>>

Execute the graph with dynamic task injection support.

After each node completes, checks the task_inbox for newly submitted tasks. If tasks are found, uses the provided planner to convert them into new nodes/edges and injects them into the runtime registries before continuing.

Source§

impl<S: StateSchema> CompiledGraph<S>

Source

pub async fn stream(&self, input: S) -> GraphResult<Vec<StreamEvent<S>>>

Source§

impl<S: StateSchema> CompiledGraph<S>

Source

pub fn validate(&self) -> GraphResult<()>

Source§

impl<S: StateSchema> CompiledGraph<S>

Source

pub fn visualize_ascii(&self) -> String

Visualize the graph structure in ASCII format

Source

pub fn visualize_mermaid(&self) -> String

Visualize the graph structure in Mermaid format

Source

pub fn visualize_json(&self) -> Value

Visualize the graph structure as JSON

Source

pub fn to_definition(&self) -> GraphDefinition

Trait Implementations§

Source§

impl<S: StateSchema> Debug for CompiledGraph<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for CompiledGraph<S>

§

impl<S> !UnwindSafe for CompiledGraph<S>

§

impl<S> Freeze for CompiledGraph<S>

§

impl<S> Send for CompiledGraph<S>

§

impl<S> Sync for CompiledGraph<S>

§

impl<S> Unpin for CompiledGraph<S>

§

impl<S> UnsafeUnpin for CompiledGraph<S>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.