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>
impl<S: StateSchema> CompiledGraph<S>
pub fn with_checkpointer<C: Checkpointer<S> + 'static>( self, checkpointer: C, ) -> Self
pub fn with_recursion_limit(self, limit: usize) -> Self
pub fn with_interrupt_before(self, nodes: Vec<String>) -> Self
pub fn with_interrupt_after(self, nodes: Vec<String>) -> Self
pub fn node_names(&self) -> Vec<String>
pub fn get_edges(&self) -> &[GraphEdge]
pub fn entry_point(&self) -> &str
pub fn recursion_limit(&self) -> usize
pub fn interrupt_before(&self) -> &[String]
pub fn interrupt_after(&self) -> &[String]
Sourcepub async fn last_checkpoint_state(&self) -> Option<S>
pub async fn last_checkpoint_state(&self) -> Option<S>
Get the last checkpoint state (for interrupt recovery)
Sourcepub async fn create_resume_execution(
&self,
interrupted_node: &str,
) -> Option<GraphExecution<S>>
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”
Sourcepub fn submit_task(&self, description: String)
pub fn submit_task(&self, description: String)
Submit a new task for dynamic planning mid-execution
Sourcepub async fn inject_node(
&self,
name: &str,
node: Arc<dyn GraphNode<S>>,
) -> GraphResult<()>
pub async fn inject_node( &self, name: &str, node: Arc<dyn GraphNode<S>>, ) -> GraphResult<()>
Inject a runtime node directly
Sourcepub async fn inject_edge(&self, source: &str, target: &str) -> GraphResult<()>
pub async fn inject_edge(&self, source: &str, target: &str) -> GraphResult<()>
Inject a runtime edge directly
Sourcepub 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<()>
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>
impl<S: StateSchema> CompiledGraph<S>
pub async fn invoke(&self, input: S) -> GraphResult<GraphInvocation<S>>
pub async fn invoke_with_execution( &self, execution: GraphExecution<S>, ) -> GraphResult<GraphInvocation<S>>
pub async fn resume( &self, execution: GraphExecution<S>, ) -> GraphResult<GraphInvocation<S>>
pub async fn invoke_from_node( &self, start_node: String, input: S, ) -> GraphResult<GraphInvocation<S>>
Source§impl<S: StateSchema> CompiledGraph<S>
impl<S: StateSchema> CompiledGraph<S>
pub async fn invoke_parallel( &self, input: S, ) -> GraphResult<ParallelInvocation<S>>
Sourcepub async fn invoke_dynamic(
&self,
input: S,
planner: &dyn DynamicPlanner<S>,
) -> GraphResult<GraphInvocation<S>>
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 + Send + Sync + 'static> CompiledGraph<S>
impl<S: StateSchema + Send + Sync + 'static> CompiledGraph<S>
Sourcepub fn stream(
&self,
input: S,
) -> Pin<Box<dyn Stream<Item = Result<StreamEvent<S>, GraphError>> + Send>>
pub fn stream( &self, input: S, ) -> Pin<Box<dyn Stream<Item = Result<StreamEvent<S>, GraphError>> + Send>>
Stream graph execution as a true async stream.
Each StreamEvent is emitted as soon as it occurs (node entry,
node completion, state update), enabling real-time consumption.
This is the preferred streaming API. For the old all-at-once
behavior, use stream_collected().
Sourcepub async fn stream_collected(
&self,
input: S,
) -> GraphResult<Vec<StreamEvent<S>>>
pub async fn stream_collected( &self, input: S, ) -> GraphResult<Vec<StreamEvent<S>>>
Collect all stream events into a Vec (backward-compatible API).
This is the old stream() behavior. Prefer stream() for
real-time consumption.
Source§impl<S: StateSchema> CompiledGraph<S>
impl<S: StateSchema> CompiledGraph<S>
pub fn validate(&self) -> GraphResult<()>
Source§impl<S: StateSchema> CompiledGraph<S>
impl<S: StateSchema> CompiledGraph<S>
Sourcepub fn visualize_ascii(&self) -> String
pub fn visualize_ascii(&self) -> String
Visualize the graph structure in ASCII format
Sourcepub fn visualize_mermaid(&self) -> String
pub fn visualize_mermaid(&self) -> String
Visualize the graph structure in Mermaid format
Sourcepub fn visualize_json(&self) -> Value
pub fn visualize_json(&self) -> Value
Visualize the graph structure as JSON
pub fn to_definition(&self) -> GraphDefinition
Trait Implementations§
Source§impl<S: Clone + StateSchema> Clone for CompiledGraph<S>
impl<S: Clone + StateSchema> Clone for CompiledGraph<S>
Source§fn clone(&self) -> CompiledGraph<S>
fn clone(&self) -> CompiledGraph<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more