Expand description
Graph-based Workflow Engine with Cycle Support
A LangGraph-inspired execution engine that supports:
- Cycles for iterative reasoning loops
- Conditional edges with dynamic routing
- State checkpointing and recovery
- Parallel branch execution
- Maximum iteration limits to prevent infinite loops
§Example
ⓘ
use cortexai_crew::graph::{Graph, GraphBuilder, StateGraph};
// Create a reasoning loop that iterates until done
let graph = GraphBuilder::new("reasoning_loop")
.add_node("think", think_node)
.add_node("act", act_node)
.add_node("evaluate", evaluate_node)
.add_edge("think", "act")
.add_edge("act", "evaluate")
// Conditional: loop back to think or finish
.add_conditional_edge("evaluate", |state| {
if state.get("done").unwrap_or(&false) {
"END"
} else {
"think" // Loop back
}
})
.set_entry("think")
.set_finish("END")
.build()?;
let result = graph.invoke(initial_state).await?;Structs§
- Checkpoint
- State checkpoint for recovery
- Condition
Router - Condition-based router
- FnNode
- Simple function wrapper for node execution
- FnRouter
- Simple function-based router
- Graph
- The main graph structure
- Graph
Builder - Builder for creating graphs
- Graph
Config - Graph configuration
- Graph
Metadata - Execution metadata
- Graph
Node - A node in the graph
- Graph
Result - Result of graph execution
- Graph
State - Graph state - the data that flows through the graph
- Graph
Stream - Streaming graph execution
- InMemory
Checkpoint Store - In-memory checkpoint store
- State
Graph - StateGraph - a higher-level API for common patterns
Enums§
- Graph
Edge - Edge types in the graph
- Graph
Status - Graph execution status
Constants§
Traits§
- Checkpoint
Store - Checkpoint storage trait
- Edge
Router - Router for conditional edges
- NodeFn
- Function type for node execution