memory.rs — Memory Engine & Recall

The memory subsystem in Oxyde stores, ranks, and retrieves agent experiences. It is critical to long-term coherence, emotional relevance, and contextual prompting.

📦 Core Structs

pub struct Memory {
    pub text: String,
    pub timestamp: u64,
    pub tags: Vec<String>,
    pub emotion_vector: EmotionVector,
    pub importance: f32,
}

pub struct MemoryManager {
    pub memories: Vec<Memory>,
}
  • Each memory has emotional metadata and a subjective importance score.

  • Memories decay over time unless reinforced.


🔍 Recall Logic

The core method for memory retrieval is:

fn recall(&self, query: &str, top_k: usize) -> Vec<Memory>

It uses:

  • TF-IDF-style string similarity

  • Emotion vector alignment (valence-aware)

  • Recency and priority weighting

Recall is weighted so emotionally significant or frequently accessed memories are more likely to surface.


🧠 Writing New Memories

You can store memories manually:

agent.memory.store("He gave me the crystal.", Some("important"));

Or let them be auto-written after every LLM response via Agent::receive_input.


🔁 Memory Decay & Compression (WIP)

Future roadmap includes:

  • Memory decay based on age & access

  • Compression of low-priority memories

  • Persistent DB-backed memory


💡 Use Cases

  • Agent remembers specific player actions

  • NPC personalities evolve over time

  • Behavior changes based on past relationships