Skip to main content

WorkflowExecutionHooks

Trait WorkflowExecutionHooks 

Source
pub trait WorkflowExecutionHooks {
    // Required methods
    fn execute_subagent<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        ctx: WorkflowDispatchRun<'life1>,
        node: &'life2 SubagentNode,
        resolved_prompt: String,
    ) -> Pin<Box<dyn Future<Output = Result<WorkflowDispatchOutcome>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn execute_host_executor<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        ctx: WorkflowDispatchRun<'life1>,
        node: &'life2 HostExecutorNode,
        parsed_input: Value,
    ) -> Pin<Box<dyn Future<Output = Result<WorkflowDispatchOutcome>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn prepare_host_executor(
        &self,
        executor_name: &str,
        resolved_input: &Value,
    ) -> Result<HostExecutorPrepareResult> { ... }
    fn recover_dangling_effects<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        _log: &'life1 mut EventLog,
        snapshot: &'life2 RunSnapshotDTO,
    ) -> Pin<Box<dyn Future<Output = Result<RecoveryResult>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn on_activities_cancelled<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        _activity_ids: &'life1 [String],
        _node_ids: &'life2 [String],
        _run_id: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}

Required Methods§

Source

fn execute_subagent<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, ctx: WorkflowDispatchRun<'life1>, node: &'life2 SubagentNode, resolved_prompt: String, ) -> Pin<Box<dyn Future<Output = Result<WorkflowDispatchOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn execute_host_executor<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, ctx: WorkflowDispatchRun<'life1>, node: &'life2 HostExecutorNode, parsed_input: Value, ) -> Pin<Box<dyn Future<Output = Result<WorkflowDispatchOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Provided Methods§

Source

fn prepare_host_executor( &self, executor_name: &str, resolved_input: &Value, ) -> Result<HostExecutorPrepareResult>

Prepare a host-executor call: parse/validate the resolved input and return the parsed form, the canonical (effect) form, and the provider metadata. Called by the runtime before writing effect-input.json and emitting effectAttempted.

The default implementation uses get_host_executor_provider_meta for provider/TTL and treats resolved_input as both parsed and canonical input — matching the legacy behaviour.

Source

fn recover_dangling_effects<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, _log: &'life1 mut EventLog, snapshot: &'life2 RunSnapshotDTO, ) -> Pin<Box<dyn Future<Output = Result<RecoveryResult>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Attempt to recover dangling effects before the next tick.

Called by run_loop before each run_tick to resolve any activities that were left in a dangling state (e.g. effectAttempted was written but the daemon crashed before writing a terminal event).

The hook should inspect snapshot.dangling.effect_attempted and, for each matching provider, attempt reconciliation (idempotent re-submit, read-only lookup, or manual failure). It writes events directly to log. The runtime will re-read the snapshot on the next loop iteration, picking up any terminal events written here.

The default implementation does nothing (no recovery).

Source

fn on_activities_cancelled<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, _activity_ids: &'life1 [String], _node_ids: &'life2 [String], _run_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Called after check_pending_cancels has written cancel events for the given activities and nodes. The hook receives the lists of activity IDs that were just cancelled, allowing daemon-level cancellation registries to cancel active dispatch tokens.

Default implementation is a no-op.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§