pub struct AgenticDB {
pub reflexion: Arc<RwLock<ReflexionMemory>>,
pub skills: Arc<RwLock<SkillLibrary>>,
pub causal: Arc<RwLock<CausalMemory>>,
pub sessions: Arc<RwLock<Vec<LearningSession>>>,
pub temporal: Arc<RwLock<TemporalMemory>>,
pub meta: Arc<RwLock<MetaLearner>>,
pub experiences: Arc<RwLock<ExperienceWindow>>,
pub drift_detector: Arc<RwLock<DriftDetector>>,
/* private fields */
}Expand description
AgenticDB: Complete agent memory system.
Provides persistent memory for AI agents with:
- Self-reflection and learning from mistakes
- Skill consolidation and reuse
- Causal reasoning over relationships
- Reinforcement learning from sessions
- Temporal pattern detection (time crystals)
- Online/continual learning with forgetting prevention
- Meta-learning for quick adaptation
Fields§
§reflexion: Arc<RwLock<ReflexionMemory>>Reflexion episodes for self-critique.
skills: Arc<RwLock<SkillLibrary>>Library of learned skills.
causal: Arc<RwLock<CausalMemory>>Causal relationships between concepts.
sessions: Arc<RwLock<Vec<LearningSession>>>Learning sessions with rewards.
temporal: Arc<RwLock<TemporalMemory>>Temporal patterns (time crystals).
meta: Arc<RwLock<MetaLearner>>Meta-learner for quick task adaptation.
experiences: Arc<RwLock<ExperienceWindow>>Experience window for continual learning.
drift_detector: Arc<RwLock<DriftDetector>>Distribution drift detector.
Implementations§
Source§impl AgenticDB
impl AgenticDB
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new in-memory AgenticDB.
§Arguments
meta_param_dim- Dimension of meta-learning parameters (default 64)drift_feature_dim- Dimension of features for drift detection (default 64)
Sourcepub fn with_dimensions(meta_param_dim: usize, drift_feature_dim: usize) -> Self
pub fn with_dimensions(meta_param_dim: usize, drift_feature_dim: usize) -> Self
Create with specific dimensions for meta-learning.
Sourcepub async fn add_reflexion(&self, episode: ReflexionEpisode)
pub async fn add_reflexion(&self, episode: ReflexionEpisode)
Record a reflexion episode (self-critique).
§Example
use converge_knowledge::agentic::{AgenticDB, ReflexionEpisode, Critique, CritiqueType};
let db = AgenticDB::new();
// Agent attempted something and failed
let episode = ReflexionEpisode::new(
"write_code",
"Write a function to parse JSON",
"fn parse() { /* incomplete */ }",
false, // did not succeed
)
.with_critique(Critique::new(
CritiqueType::MissingStep,
"Did not handle error cases",
"Add Result return type and error handling",
));
db.add_reflexion(episode).await;Sourcepub async fn query_similar_failures(
&self,
task: &str,
limit: usize,
) -> Vec<ReflexionEpisode>
pub async fn query_similar_failures( &self, task: &str, limit: usize, ) -> Vec<ReflexionEpisode>
Query similar past failures to avoid repeating mistakes.
Sourcepub async fn register_skill(&self, skill: Skill)
pub async fn register_skill(&self, skill: Skill)
Register a successful skill pattern.
Sourcepub async fn find_skills(&self, _task_description: &str) -> Vec<&Skill>
pub async fn find_skills(&self, _task_description: &str) -> Vec<&Skill>
Find applicable skills for a task.
Sourcepub async fn add_causal_link(
&self,
cause: Uuid,
effect: Uuid,
relationship: impl Into<String>,
strength: f32,
)
pub async fn add_causal_link( &self, cause: Uuid, effect: Uuid, relationship: impl Into<String>, strength: f32, )
Add a causal relationship.
Sourcepub async fn start_session(&self, goal: impl Into<String>) -> Uuid
pub async fn start_session(&self, goal: impl Into<String>) -> Uuid
Start a new learning session.
Sourcepub async fn record_turn(
&self,
session_id: Uuid,
action: impl Into<String>,
observation: impl Into<String>,
reward: Reward,
)
pub async fn record_turn( &self, session_id: Uuid, action: impl Into<String>, observation: impl Into<String>, reward: Reward, )
Record a turn in a session.
Sourcepub async fn stats(&self) -> AgenticStats
pub async fn stats(&self) -> AgenticStats
Get statistics about the agent memory.
Sourcepub async fn record_temporal(
&self,
pattern_name: &str,
period: TemporalPeriod,
value: f32,
)
pub async fn record_temporal( &self, pattern_name: &str, period: TemporalPeriod, value: f32, )
Record a temporal pattern (time crystal).
Use this to track periodic behavior patterns like:
- Daily coding activity
- Weekly deployment schedules
- Monthly review cycles
Sourcepub async fn predict_temporal(&self, pattern_name: &str) -> Option<f32>
pub async fn predict_temporal(&self, pattern_name: &str) -> Option<f32>
Predict activity for a temporal pattern.
Sourcepub async fn add_experience(
&mut self,
features: Vec<f32>,
target: f32,
task_id: Option<String>,
)
pub async fn add_experience( &mut self, features: Vec<f32>, target: f32, task_id: Option<String>, )
Add experience for continual learning.
Sourcepub async fn check_drift(&self, features: &[f32]) -> bool
pub async fn check_drift(&self, features: &[f32]) -> bool
Check for distribution drift.
Returns true if the current features indicate a distribution shift that may require model adaptation.
Sourcepub async fn meta_update(
&self,
task_id: &str,
final_params: &[f32],
task_embedding: Option<Vec<f32>>,
)
pub async fn meta_update( &self, task_id: &str, final_params: &[f32], task_embedding: Option<Vec<f32>>, )
Update meta-learner after completing a task.
Sourcepub async fn get_task_initialization(
&self,
task_embedding: Option<&[f32]>,
) -> Vec<f32>
pub async fn get_task_initialization( &self, task_embedding: Option<&[f32]>, ) -> Vec<f32>
Get initialization parameters for a new task.
Sourcepub async fn register_strategy(&self, strategy: LearningStrategy)
pub async fn register_strategy(&self, strategy: LearningStrategy)
Register a learning strategy.
Sourcepub async fn select_strategy(
&self,
task_features: &TaskFeatures,
) -> Option<String>
pub async fn select_strategy( &self, task_features: &TaskFeatures, ) -> Option<String>
Select best strategy for a task.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AgenticDB
impl !RefUnwindSafe for AgenticDB
impl Send for AgenticDB
impl Sync for AgenticDB
impl Unpin for AgenticDB
impl UnsafeUnpin for AgenticDB
impl !UnwindSafe for AgenticDB
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request