pub struct StateGraphExecutor { /* private fields */ }Expand description
Executor for StateGraph — walks cyclic graph with conditional routing.
The executor processes a StateGraph by:
- Starting at the
entry_pointnode - Executing each node’s
NodeActionvia theGraphActionExecutor - Evaluating outgoing
EdgeConditions to select the next node - Handling interrupt points (nodes marked with
interrupt: true) - Terminating when a terminal node is reached or max iterations exceeded
P2-2: The executor now uses a GraphActionExecutor for node action execution.
This enables AgentLoop integration — when an AgentLoopGraphActionExecutor
(from oneai-agent) is provided, LlmInfer/ToolCall nodes delegate to the
AgentLoop’s full pipeline (hooks, permission, domain pack, tool definitions).
Template interpolation ({{variable}}) is still applied to tool_name and
args_template fields before tool execution, using GraphState.variables.
Implementations§
Source§impl StateGraphExecutor
impl StateGraphExecutor
Sourcepub fn new(
action_executor: Arc<dyn GraphActionExecutor>,
delegate_factory: Arc<dyn DelegateFactory>,
interaction_gate: Arc<dyn InteractionGate>,
max_iterations: usize,
) -> Self
pub fn new( action_executor: Arc<dyn GraphActionExecutor>, delegate_factory: Arc<dyn DelegateFactory>, interaction_gate: Arc<dyn InteractionGate>, max_iterations: usize, ) -> Self
Create a new StateGraphExecutor with a GraphActionExecutor.
This is the P2-2 constructor — when an AgentLoopGraphActionExecutor
is provided, LlmInfer/ToolCall nodes get full AgentLoop integration.
Sourcepub fn with_defaults(
action_executor: Arc<dyn GraphActionExecutor>,
delegate_factory: Arc<dyn DelegateFactory>,
interaction_gate: Arc<dyn InteractionGate>,
) -> Self
pub fn with_defaults( action_executor: Arc<dyn GraphActionExecutor>, delegate_factory: Arc<dyn DelegateFactory>, interaction_gate: Arc<dyn InteractionGate>, ) -> Self
Create with default max_iterations (50).
Sourcepub fn with_direct_provider(
provider: Arc<dyn LlmProvider>,
tools: Arc<RwLock<HashMap<String, Arc<dyn Tool>>>>,
delegate_factory: Arc<dyn DelegateFactory>,
interaction_gate: Arc<dyn InteractionGate>,
max_iterations: usize,
) -> Self
pub fn with_direct_provider( provider: Arc<dyn LlmProvider>, tools: Arc<RwLock<HashMap<String, Arc<dyn Tool>>>>, delegate_factory: Arc<dyn DelegateFactory>, interaction_gate: Arc<dyn InteractionGate>, max_iterations: usize, ) -> Self
Create with direct provider + tools (backward-compatible constructor).
This constructor creates a DirectProviderActionExecutor internally,
providing the same behavior as the original StateGraphExecutor (before P2-2).
Use this when you don’t have an AgentLoop available (e.g., standalone
StateGraph execution without AgentLoop integration).
Sourcepub fn with_direct_provider_defaults(
provider: Arc<dyn LlmProvider>,
tools: Arc<RwLock<HashMap<String, Arc<dyn Tool>>>>,
delegate_factory: Arc<dyn DelegateFactory>,
interaction_gate: Arc<dyn InteractionGate>,
) -> Self
pub fn with_direct_provider_defaults( provider: Arc<dyn LlmProvider>, tools: Arc<RwLock<HashMap<String, Arc<dyn Tool>>>>, delegate_factory: Arc<dyn DelegateFactory>, interaction_gate: Arc<dyn InteractionGate>, ) -> Self
Create with direct provider + default max_iterations (50).
Backward-compatible with the original with_defaults() constructor.
Sourcepub async fn execute(
&self,
graph: &StateGraph,
initial_state: GraphState,
) -> Result<GraphExecutionResult>
pub async fn execute( &self, graph: &StateGraph, initial_state: GraphState, ) -> Result<GraphExecutionResult>
Execute a StateGraph starting from its entry point.
Walks the graph, executing each node’s action and routing to the next node based on edge conditions. Returns a GraphExecutionResult with the final state, completion status, and iteration count.