Skip to main content

MemoryProvider

Trait MemoryProvider 

Source
pub trait MemoryProvider: Send + Sync {
    // Required methods
    fn system_prompt_block(
        &self,
        request: &SystemPromptRequest,
    ) -> Result<SystemPromptResponse>;
    fn prefetch<'life0, 'async_trait>(
        &'life0 self,
        request: PrefetchRequest,
    ) -> Pin<Box<dyn Future<Output = Result<PrefetchResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn sync_turn<'life0, 'async_trait>(
        &'life0 self,
        request: SyncTurnRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SyncTurnResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_session_end<'life0, 'async_trait>(
        &'life0 self,
        request: SessionEndRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SessionEndResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Isolation layer between Agent-Diva and any long-memory backend.

Contract rules:

  • system_prompt_block() is synchronous because prompt assembly in ContextBuilder::build_system_prompt() is synchronous today.
  • prefetch(), sync_turn(), and on_session_end() are async because live-turn recall, post-turn persistence, and shutdown rhythm work may require I/O and already sit on async paths in Agent-Diva.
  • All request/response types are Agent-Diva-owned domain structs; do not leak MCP schemas, CLI arguments, HTTP routes, or backend model types.

Required Methods§

Source

fn system_prompt_block( &self, request: &SystemPromptRequest, ) -> Result<SystemPromptResponse>

Build the startup memory block for system prompt assembly.

Source

fn prefetch<'life0, 'async_trait>( &'life0 self, request: PrefetchRequest, ) -> Pin<Box<dyn Future<Output = Result<PrefetchResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform optional intent-aware prefetch for a live turn.

Source

fn sync_turn<'life0, 'async_trait>( &'life0 self, request: SyncTurnRequest, ) -> Pin<Box<dyn Future<Output = Result<SyncTurnResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persist evidence after a successful turn completes.

Source

fn on_session_end<'life0, 'async_trait>( &'life0 self, request: SessionEndRequest, ) -> Pin<Box<dyn Future<Output = Result<SessionEndResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Trigger shutdown/session-end rhythm work if needed.

Implementors§