Skip to main content

ContextStore

Trait ContextStore 

Source
pub trait ContextStore: Send + Sync {
    // Required methods
    fn memorize<'life0, 'async_trait>(
        &'life0 self,
        frag: ContextFragment,
    ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn recall<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 RecallQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ContextFragment>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn compact<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<ContextFragment, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_by_key<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        session: &'life1 str,
        key: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ContextFragment>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session: &'life1 str,
        top_k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ContextFragment>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

The unified context-memory contract. Everything that needs conversational or long-term context goes through this trait.

Implementations:

  • aria-agent-memo::MemoContextStore — on-device / local (aria memo, SQLite),
  • aria-agent-cloud::context::PgContextStore — cloud (Postgres + pgvector),
  • CompositeContextStoreboth: writes to two stores, reads merged.

Required Methods§

Source

fn memorize<'life0, 'async_trait>( &'life0 self, frag: ContextFragment, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Persist a fragment.

Source

fn recall<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 RecallQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<ContextFragment>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve the most relevant fragments for a query.

Source

fn compact<'life0, 'life1, 'async_trait>( &'life0 self, session: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<ContextFragment, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Merge a session’s fragments into a single compact fragment.

Source

fn get_by_key<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ContextFragment>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Lookup an explicit long-term memory by key (used by SDK recall).

Source

fn list_session<'life0, 'life1, 'async_trait>( &'life0 self, session: &'life1 str, top_k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<ContextFragment>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Every fragment of a session, oldest first (used by compact and by the session memory listing).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§