pub struct WorkflowExecutor { /* private fields */ }Expand description
Workflow executor — runs a compiled DAG.
The executor processes the DAG level by level:
- Level 0: all root nodes run concurrently
- Level 1: nodes that depend only on level 0 nodes run concurrently
- Level N: nodes that depend only on earlier levels run concurrently
Between levels, the WorkflowContext is updated with step results.
Template interpolation ({{variable}}) is applied to tool_args and
prompt fields before step execution, using context variables and
previous step outputs.
When a provider is available, prompt-based steps (steps with a prompt
field but no tool) execute actual LLM inference instead of just
returning the prompt text.
Implementations§
Source§impl WorkflowExecutor
impl WorkflowExecutor
Sourcepub fn new(
tools: Arc<HashMap<String, Arc<dyn Tool>>>,
interaction_gate: Arc<dyn InteractionGate>,
) -> Self
pub fn new( tools: Arc<HashMap<String, Arc<dyn Tool>>>, interaction_gate: Arc<dyn InteractionGate>, ) -> Self
Create a new executor with tools and approval gate.
Sourcepub fn new_empty(interaction_gate: Arc<dyn InteractionGate>) -> Self
pub fn new_empty(interaction_gate: Arc<dyn InteractionGate>) -> Self
Create a new executor with an empty tool registry.
Tools can be registered later via register_tool().
Sourcepub fn with_provider(
tools: Arc<HashMap<String, Arc<dyn Tool>>>,
interaction_gate: Arc<dyn InteractionGate>,
provider: Arc<dyn LlmProvider>,
) -> Self
pub fn with_provider( tools: Arc<HashMap<String, Arc<dyn Tool>>>, interaction_gate: Arc<dyn InteractionGate>, provider: Arc<dyn LlmProvider>, ) -> Self
Create a new executor with tools, approval gate, and LLM provider. With a provider, prompt-based steps will execute actual LLM inference.
Sourcepub fn with_permission_resolver(
self,
resolver: Arc<dyn PermissionResolver>,
) -> Self
pub fn with_permission_resolver( self, resolver: Arc<dyn PermissionResolver>, ) -> Self
Attach a domain permission resolver so tool steps honour DomainPack
deny_by_default / require_confirmation policy on this path.
Sourcepub fn set_provider(&mut self, provider: Arc<dyn LlmProvider>)
pub fn set_provider(&mut self, provider: Arc<dyn LlmProvider>)
Set the LLM provider for prompt-based steps.
When set, steps with a prompt field but no tool will call
the provider for actual inference instead of returning raw text.
Sourcepub async fn register_tool(&self, tool: Arc<dyn Tool>)
pub async fn register_tool(&self, tool: Arc<dyn Tool>)
Register a tool for workflow step execution.
Sourcepub fn tools_handle(&self) -> Arc<RwLock<HashMap<String, Arc<dyn Tool>>>> ⓘ
pub fn tools_handle(&self) -> Arc<RwLock<HashMap<String, Arc<dyn Tool>>>> ⓘ
Get a handle to the internal tool registry (Arc<RwLock
Sourcepub async fn execute(
&self,
dag: &WorkflowDag,
config: &WorkflowConfig,
) -> Result<WorkflowResult>
pub async fn execute( &self, dag: &WorkflowDag, config: &WorkflowConfig, ) -> Result<WorkflowResult>
Execute a workflow DAG.
Runs the DAG level by level, with steps at the same level executing concurrently. Returns a WorkflowResult with the status of each step.