Skip to main content

ExecutionStore

Trait ExecutionStore 

Source
pub trait ExecutionStore: Send + Sync {
    // Required methods
    fn record_execution<'life0, 'async_trait>(
        &'life0 self,
        execution: ToolExecution,
    ) -> Pin<Box<dyn Future<Output = StoreResult<ToolExecution>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_executions<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<ToolExecution>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_executions_by_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<ToolExecution>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn record_usage<'life0, 'async_trait>(
        &'life0 self,
        record: UsageRecord,
    ) -> Pin<Box<dyn Future<Output = StoreResult<UsageRecord>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_usage<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<UsageRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn session_stats<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = StoreResult<SessionStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn delete_by_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = StoreResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Persists tool execution records and token usage, and provides session analytics.

Implementations must be Send + Sync. Backends include in-memory, PostgreSQL, MySQL, and SQLite (via sqlx).

Required Methods§

Source

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

Records a tool execution and returns it with server-assigned fields.

Source

fn list_executions<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<ToolExecution>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns all tool executions for a session ordered by creation time (ascending).

Source

fn list_executions_by_message<'life0, 'life1, 'async_trait>( &'life0 self, message_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<ToolExecution>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns all tool executions for a specific message ordered by creation time.

Source

fn record_usage<'life0, 'async_trait>( &'life0 self, record: UsageRecord, ) -> Pin<Box<dyn Future<Output = StoreResult<UsageRecord>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Records token usage for a single provider interaction.

Source

fn list_usage<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = StoreResult<Vec<UsageRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns all usage records for a session ordered by creation time (ascending).

Source

fn session_stats<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = StoreResult<SessionStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Computes aggregate statistics for a session.

Returns pre-computed or live-aggregated stats including message counts, tool call counts, and cumulative token usage.

Provided Methods§

Source

fn delete_by_session<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = StoreResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes all executions and usage records for a session.

Returns the number of records deleted. Default implementation is a no-op returning 0.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§