Skip to main content

ContextManager

Trait ContextManager 

Source
pub trait ContextManager: Send + Sync {
    // Required methods
    fn store_context<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
        context: AgentContext,
    ) -> Pin<Box<dyn Future<Output = Result<ContextId, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn retrieve_context<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
        session_id: Option<SessionId>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<AgentContext>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn query_context<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
        query: ContextQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ContextItem>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update_memory<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
        memory_updates: Vec<MemoryUpdate>,
    ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_knowledge<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
        knowledge: Knowledge,
    ) -> Pin<Box<dyn Future<Output = Result<KnowledgeId, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search_knowledge<'life0, 'life1, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
        query: &'life1 str,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<KnowledgeItem>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn share_knowledge<'life0, 'async_trait>(
        &'life0 self,
        from_agent: AgentId,
        to_agent: AgentId,
        knowledge_id: KnowledgeId,
        access_level: AccessLevel,
    ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_shared_knowledge<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<SharedKnowledgeRef>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn archive_context<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
        before: SystemTime,
    ) -> Pin<Box<dyn Future<Output = Result<u32, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_context_stats<'life0, 'async_trait>(
        &'life0 self,
        agent_id: AgentId,
    ) -> Pin<Box<dyn Future<Output = Result<ContextStats, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Context Manager trait for agent memory and knowledge management

Required Methods§

Source

fn store_context<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, context: AgentContext, ) -> Pin<Box<dyn Future<Output = Result<ContextId, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store agent context

Source

fn retrieve_context<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, session_id: Option<SessionId>, ) -> Pin<Box<dyn Future<Output = Result<Option<AgentContext>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve agent context

Source

fn query_context<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, query: ContextQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<ContextItem>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Query context with semantic search

Source

fn update_memory<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, memory_updates: Vec<MemoryUpdate>, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update specific memory items

Source

fn add_knowledge<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, knowledge: Knowledge, ) -> Pin<Box<dyn Future<Output = Result<KnowledgeId, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add knowledge to agent’s knowledge base

Source

fn search_knowledge<'life0, 'life1, 'async_trait>( &'life0 self, agent_id: AgentId, query: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<KnowledgeItem>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search knowledge base

Source

fn share_knowledge<'life0, 'async_trait>( &'life0 self, from_agent: AgentId, to_agent: AgentId, knowledge_id: KnowledgeId, access_level: AccessLevel, ) -> Pin<Box<dyn Future<Output = Result<(), ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Share knowledge between agents

Source

fn get_shared_knowledge<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, ) -> Pin<Box<dyn Future<Output = Result<Vec<SharedKnowledgeRef>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get shared knowledge available to agent

Source

fn archive_context<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, before: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<u32, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Archive old context based on retention policy

Source

fn get_context_stats<'life0, 'async_trait>( &'life0 self, agent_id: AgentId, ) -> Pin<Box<dyn Future<Output = Result<ContextStats, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get context statistics

Source

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

Shutdown the context manager gracefully

Implementors§