Memory Model
The core Memory
class is the fundamental building block of Reeflect, representing a discrete piece of information that can be stored, retrieved, and reasoned with.
Memory Structure
@dataclass
class Memory:
# Core fields
id: str = field(default_factory=lambda: str(uuid.uuid4()))
content: str = "" # The actual content of the memory
namespace: str = "default" # Organizational namespace
memory_type: MemoryType = MemoryType.PERSISTENT
status: MemoryStatus = MemoryStatus.ACTIVE
# Metadata and tracking
created_at: datetime = field(default_factory=datetime.now)
updated_at: datetime = field(default_factory=datetime.now)
last_accessed: Optional[datetime] = None
access_count: int = 0
# Semantic understanding
embedding: Optional[List[float]] = None # Vector embedding
tags: List[str] = field(default_factory=list) # Categorical tags
# Intelligence attributes
importance: float = 0.5 # Importance score (0.0-1.0)
confidence: float = 1.0 # Confidence in accuracy (0.0-1.0)
metadata: Dict[str, Any] = field(default_factory=dict)
# Relationships
relations: List[MemoryRelation] = field(default_factory=list)
# Access control
permissions: MemoryPermissions = field(default_factory=lambda:
MemoryPermissions(owner="system"))
Memory Types
Type | Description | Use Cases |
---|---|---|
SESSION | Temporary memory for current interaction | Current conversation, Temporary context |
PERSISTENT | Long-term stored memory | User preferences, Important facts, Recurring information |
SYNTHETIC | AI-generated or inferred memory | Summarized knowledge, Inferred preferences, Generated insights |
Memory Relationships
Memories can be connected through relationships, forming a knowledge graph structure that enables more sophisticated reasoning and retrieval.
@dataclass
class MemoryRelation:
"""Represents a relationship between memories."""
target_id: str # ID of the target memory
relation_type: MemoryRelationType # Type of relationship
confidence: float = 1.0 # Confidence in the relationship (0.0-1.0)
metadata: Dict[str, Any] = field(default_factory=dict)
The following relationship types are available:
SUPPORTS
- Memory supports or reinforces another memoryCONTRADICTS
- Memory contradicts or conflicts with another memoryEXTENDS
- Memory extends or elaborates on another memoryPRECEDES
- Memory comes before another in a sequenceFOLLOWS
- Memory comes after another in a sequenceRELATED
- General relationship without specific type
Best Practice
Use memory relationships to build a rich knowledge graph that enables more sophisticated reasoning and retrieval. Relationships help the system understand how different pieces of information connect and influence each other.
Next Steps
Explore Storage Systems to learn how Reeflect persists memories for long-term use and efficient retrieval.