pub struct AgentMemory { /* private fields */ }Expand description
Three-tier agent memory: working, short-term (session), and long-term (persisted).
Implementations§
Source§impl AgentMemory
impl AgentMemory
Sourcepub fn new(store: Arc<dyn MemoryStore>) -> Self
pub fn new(store: Arc<dyn MemoryStore>) -> Self
Create a new agent memory system with default configuration
Sourcepub fn with_config(store: Arc<dyn MemoryStore>, config: MemoryConfig) -> Self
pub fn with_config(store: Arc<dyn MemoryStore>, config: MemoryConfig) -> Self
Create a new agent memory system with custom configuration
Sourcepub async fn remember(&self, item: MemoryItem) -> Result<()>
pub async fn remember(&self, item: MemoryItem) -> Result<()>
Store a memory in long-term storage and add to short-term
Sourcepub async fn remember_success(
&self,
prompt: &str,
tools_used: &[String],
result: &str,
) -> Result<()>
pub async fn remember_success( &self, prompt: &str, tools_used: &[String], result: &str, ) -> Result<()>
Remember a successful pattern
Sourcepub async fn remember_failure(
&self,
prompt: &str,
error: &str,
attempted_tools: &[String],
) -> Result<()>
pub async fn remember_failure( &self, prompt: &str, error: &str, attempted_tools: &[String], ) -> Result<()>
Remember a failure to avoid repeating
Sourcepub async fn recall_similar(
&self,
prompt: &str,
limit: usize,
) -> Result<Vec<MemoryItem>>
pub async fn recall_similar( &self, prompt: &str, limit: usize, ) -> Result<Vec<MemoryItem>>
Recall similar past experiences
Recall by tags
Sourcepub async fn get_recent(&self, limit: usize) -> Result<Vec<MemoryItem>>
pub async fn get_recent(&self, limit: usize) -> Result<Vec<MemoryItem>>
Get recent memories
Sourcepub async fn add_to_working(&self, item: MemoryItem) -> Result<()>
pub async fn add_to_working(&self, item: MemoryItem) -> Result<()>
Add to working memory (auto-trims by relevance if over capacity)
Sourcepub async fn get_working(&self) -> Vec<MemoryItem>
pub async fn get_working(&self) -> Vec<MemoryItem>
Get working memory
Sourcepub async fn clear_working(&self)
pub async fn clear_working(&self)
Clear working memory
Sourcepub async fn get_short_term(&self) -> Vec<MemoryItem>
pub async fn get_short_term(&self) -> Vec<MemoryItem>
Get short-term memory
Sourcepub async fn clear_short_term(&self)
pub async fn clear_short_term(&self)
Clear short-term memory
Sourcepub async fn stats(&self) -> Result<MemoryStats>
pub async fn stats(&self) -> Result<MemoryStats>
Get memory statistics
Sourcepub fn store(&self) -> &Arc<dyn MemoryStore>
pub fn store(&self) -> &Arc<dyn MemoryStore>
Get access to the underlying store
Sourcepub async fn working_count(&self) -> usize
pub async fn working_count(&self) -> usize
Get working memory count
Sourcepub async fn short_term_count(&self) -> usize
pub async fn short_term_count(&self) -> usize
Get short-term memory count
Trait Implementations§
Source§impl Clone for AgentMemory
impl Clone for AgentMemory
Source§fn clone(&self) -> AgentMemory
fn clone(&self) -> AgentMemory
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AgentMemory
impl !RefUnwindSafe for AgentMemory
impl Send for AgentMemory
impl Sync for AgentMemory
impl Unpin for AgentMemory
impl UnsafeUnpin for AgentMemory
impl !UnwindSafe for AgentMemory
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more