Skip to main content

CompiledGraph

Trait CompiledGraph 

Source
pub trait CompiledGraph<S: GraphState>: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn invoke<'life0, 'async_trait>(
        &'life0 self,
        input: S,
        config: Option<RuntimeContext>,
    ) -> Pin<Box<dyn Future<Output = AgentResult<S>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stream<'life0, 'async_trait>(
        &'life0 self,
        input: S,
        config: Option<RuntimeContext>,
    ) -> Pin<Box<dyn Future<Output = AgentResult<Pin<Box<dyn Stream<Item = AgentResult<StreamEvent<S>>> + Send>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn step<'life0, 'async_trait>(
        &'life0 self,
        input: S,
        config: Option<RuntimeContext>,
    ) -> Pin<Box<dyn Future<Output = AgentResult<StepResult<S>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn validate_state(&self, state: &S) -> AgentResult<()>;
    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 = AgentResult<S>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: '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 = AgentResult<Pin<Box<dyn Stream<Item = AgentResult<StreamEvent<S>>> + Send>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: '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 = AgentResult<StepResult<S>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute a single step of the graph

Useful for debugging or interactive execution.

Source

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

Validate that a state is valid for this graph

Source

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

Get the graph’s state schema

Implementors§