Skip to main content

DurableContext

Trait DurableContext 

Source
pub trait DurableContext: WasmCompatSend + WasmCompatSync {
    // Required methods
    fn execute_llm_call(
        &self,
        request: CompletionRequest,
        options: ActivityOptions,
    ) -> impl Future<Output = Result<CompletionResponse, DurableError>> + WasmCompatSend;
    fn execute_tool(
        &self,
        tool_name: &str,
        input: Value,
        ctx: &ToolContext,
        options: ActivityOptions,
    ) -> impl Future<Output = Result<ToolOutput, DurableError>> + WasmCompatSend;
    fn wait_for_signal<T: DeserializeOwned + WasmCompatSend>(
        &self,
        signal_name: &str,
        timeout: Duration,
    ) -> impl Future<Output = Result<Option<T>, DurableError>> + WasmCompatSend;
    fn should_continue_as_new(&self) -> bool;
    fn continue_as_new(
        &self,
        state: Value,
    ) -> impl Future<Output = Result<(), DurableError>> + WasmCompatSend;
    fn sleep(
        &self,
        duration: Duration,
    ) -> impl Future<Output = ()> + WasmCompatSend;
    fn now(&self) -> DateTime<Utc>;
}
Expand description

Wraps side effects for durable execution engines (Temporal, Restate, Inngest).

When present, the agentic loop calls through this instead of directly calling provider/tools, enabling journaling, replay, and crash recovery.

Required Methods§

Source

fn execute_llm_call( &self, request: CompletionRequest, options: ActivityOptions, ) -> impl Future<Output = Result<CompletionResponse, DurableError>> + WasmCompatSend

Execute an LLM call as a durable activity.

Source

fn execute_tool( &self, tool_name: &str, input: Value, ctx: &ToolContext, options: ActivityOptions, ) -> impl Future<Output = Result<ToolOutput, DurableError>> + WasmCompatSend

Execute a tool call as a durable activity.

Source

fn wait_for_signal<T: DeserializeOwned + WasmCompatSend>( &self, signal_name: &str, timeout: Duration, ) -> impl Future<Output = Result<Option<T>, DurableError>> + WasmCompatSend

Wait for an external signal with a timeout.

Source

fn should_continue_as_new(&self) -> bool

Whether the workflow should continue-as-new to avoid history bloat.

Source

fn continue_as_new( &self, state: Value, ) -> impl Future<Output = Result<(), DurableError>> + WasmCompatSend

Continue the workflow as a new execution with the given state.

Source

fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + WasmCompatSend

Sleep for a duration (durable — survives replay).

Source

fn now(&self) -> DateTime<Utc>

Current time (deterministic during replay).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§