Skip to main content

MemoryService

Trait MemoryService 

Source
pub trait MemoryService: Send + Sync {
Show 13 methods // Required methods fn add_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, session_id: &'life3 str, entries: Vec<MemoryEntry>, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait; fn search<'life0, 'async_trait>( &'life0 self, req: SearchRequest, ) -> Pin<Box<dyn Future<Output = Result<SearchResponse, AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; // Provided methods fn delete_user<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait { ... } fn delete_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, session_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait { ... } fn add_entry<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, entry: MemoryEntry, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait { ... } fn delete_entries<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, query: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait { ... } fn list_recent<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>, AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait { ... } fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait { ... } fn supports_project_scoping(&self) -> bool { ... } fn add_session_to_project<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, session_id: &'life3 str, project_id: &'life4 str, entries: Vec<MemoryEntry>, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait { ... } fn add_entry_to_project<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, project_id: &'life3 str, entry: MemoryEntry, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait { ... } fn delete_entries_in_project<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, project_id: &'life3 str, query: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait { ... } fn delete_project<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, project_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait { ... }
}
Available on crate feature memory only.

Required Methods§

Source

fn add_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, session_id: &'life3 str, entries: Vec<MemoryEntry>, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Source

fn search<'life0, 'async_trait>( &'life0 self, req: SearchRequest, ) -> Pin<Box<dyn Future<Output = Result<SearchResponse, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Provided Methods§

Source

fn delete_user<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Delete all memory entries for a specific user.

Required for GDPR right-to-erasure compliance. Removes all stored memories (including embeddings) for the given app and user.

Source

fn delete_session<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, session_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Delete all memory entries for a specific session.

Source

fn add_entry<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, entry: MemoryEntry, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Add a single memory entry directly (not tied to a session).

Source

fn delete_entries<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, query: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Delete entries matching a query. Returns count of deleted entries.

Source

fn list_recent<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

List the most recent entries for a user (global + project-scoped), newest first. Unlike search, this is a pure recency listing — no query, no similarity ranking — suitable for “what does the agent remember?” UIs and latest-item lookups.

Source

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

Verify backend connectivity.

Returns Ok(()) if the backend is reachable and responsive. The default implementation always succeeds (suitable for in-memory).

Source

fn supports_project_scoping(&self) -> bool

Whether this backend keeps project-scoped entries isolated.

Returns false by default. A backend that implements the project methods below overrides this to true, so a caller can tell isolation apart from a backend that has no project support rather than discovering it from data.

Source

fn add_session_to_project<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, session_id: &'life3 str, project_id: &'life4 str, entries: Vec<MemoryEntry>, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Adds session entries scoped to a project.

§Errors

The default implementation returns an error. Discarding project_id and writing globally would make entries intended for one project visible to everything else under the same app and user, with nothing in the return value to say so, so a backend without project support refuses the write instead.

Source

fn add_entry_to_project<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, project_id: &'life3 str, entry: MemoryEntry, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Adds a single entry scoped to a project.

§Errors

Returns an error by default, for the reason given on MemoryService::add_session_to_project.

Source

fn delete_entries_in_project<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, project_id: &'life3 str, query: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Deletes entries matching a query within a specific project.

§Errors

Returns an error by default. Falling back to a global delete would remove entries outside the named project, which is worse than refusing.

Source

fn delete_project<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, project_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Delete all entries for a specific project. Default returns “not implemented” error.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§