Skip to main content

CompiledGraph

Trait CompiledGraph 

Source
pub trait CompiledGraph<S>: Send + Sync
where S: GraphState,
{ // Required methods fn id(&self) -> &str; fn invoke<'life0, 'async_trait>( &'life0 self, input: S, config: Option<RuntimeContext>, ) -> Pin<Box<dyn Future<Output = Result<S, AgentError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn stream<'life0, 'async_trait>( &'life0 self, input: S, config: Option<RuntimeContext>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent<S>, AgentError>> + Send>>, AgentError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn step<'life0, 'async_trait>( &'life0 self, input: S, config: Option<RuntimeContext>, ) -> Pin<Box<dyn Future<Output = Result<StepResult<S>, AgentError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; fn validate_state(&self, state: &S) -> Result<(), AgentError>; fn state_schema(&self) -> HashMap<String, String>; }
Expand description

Compiled graph trait for execution

A compiled graph can be invoked with an initial state and returns the final state after execution.

Required Methods§

Source

fn id(&self) -> &str

Get the graph ID

Source

fn invoke<'life0, 'async_trait>( &'life0 self, input: S, config: Option<RuntimeContext>, ) -> Pin<Box<dyn Future<Output = Result<S, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Execute the graph synchronously

§Arguments
  • input - Initial state
  • config - Optional runtime configuration (uses defaults if None)
§Returns

The final state after graph execution completes

Source

fn stream<'life0, 'async_trait>( &'life0 self, input: S, config: Option<RuntimeContext>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent<S>, AgentError>> + Send>>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Execute the graph with streaming output

Returns a stream of (node_id, state) pairs as each node completes.

Source

fn step<'life0, 'async_trait>( &'life0 self, input: S, config: Option<RuntimeContext>, ) -> Pin<Box<dyn Future<Output = Result<StepResult<S>, AgentError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Execute a single step of the graph

Useful for debugging or interactive execution.

Source

fn validate_state(&self, state: &S) -> Result<(), AgentError>

Validate that a state is valid for this graph

Source

fn state_schema(&self) -> HashMap<String, String>

Get the graph’s state schema

Implementors§

Source§

impl<S> CompiledGraph<S> for CompiledGraphImpl<S>
where S: GraphState + 'static,