Skip to main content

ToolExecutionStore

Trait ToolExecutionStore 

Source
pub trait ToolExecutionStore: Send + Sync {
    // Required methods
    fn get_execution<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tool_call_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ToolExecution>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn record_execution<'life0, 'async_trait>(
        &'life0 self,
        execution: ToolExecution,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update_execution<'life0, 'async_trait>(
        &'life0 self,
        execution: ToolExecution,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_execution_by_operation_id<'life0, 'life1, 'async_trait>(
        &'life0 self,
        operation_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ToolExecution>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Store for tracking tool executions (idempotency).

This trait enables write-ahead execution tracking to ensure tool idempotency. The pattern is:

  1. Record execution intent BEFORE calling the tool (record_execution)
  2. Update with result AFTER completion (update_execution)
  3. On retry, check if execution exists and return cached result

Required Methods§

Source

fn get_execution<'life0, 'life1, 'async_trait>( &'life0 self, tool_call_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolExecution>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an execution by tool_call_id.

§Errors

Returns an error if the execution cannot be retrieved.

Source

fn record_execution<'life0, 'async_trait>( &'life0 self, execution: ToolExecution, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record a new execution (write-ahead, before calling tool).

§Errors

Returns an error if the execution cannot be recorded.

Source

fn update_execution<'life0, 'async_trait>( &'life0 self, execution: ToolExecution, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update an existing execution (after completion or to set operation_id).

§Errors

Returns an error if the execution cannot be updated.

Source

fn get_execution_by_operation_id<'life0, 'life1, 'async_trait>( &'life0 self, operation_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolExecution>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get execution by operation_id (for async tool resume).

§Errors

Returns an error if the execution cannot be retrieved.

Implementors§