Skip to content

research(memory): AOI three-layer hierarchical memory architecture #1839

@bug-ops

Description

@bug-ops

Research Finding

Paper: AOI — Three-Layer Hierarchical Memory Compression (arXiv:2512.13956)
Related: arXiv:2501.11739 (Jan 2025), arXiv:2512.13564

Three-layer architecture: Working memory (active context) → Episodic memory (recent interaction traces) → Semantic memory (consolidated long-term facts). LLM-based compression at layer boundaries achieves 72.4% context reduction while preserving critical information through selective consolidation.

Applicability to Zeph

Zeph's memory is currently flat (SQLite rows + Qdrant vectors). A three-tier promotion pipeline maps directly onto existing infrastructure:

  • Working memory → active messages[] context window (already exists)
  • Episodic memory → SQLite messages table + recent Qdrant entries (already exists, but promotion logic is missing)
  • Semantic memory → Qdrant zeph_key_facts / zeph_session_summaries (already exists)

Missing piece: explicit promotion thresholds at each boundary — rules for when episodic entries graduate to semantic, and when working memory entries age into episodic. Currently all compaction flows directly from working memory to semantic (via summarize_messages), skipping a proper episodic staging tier.

Memory Tier Design

Tier Table Retention Retrieval weight
Episodic messages decays (Ebbinghaus) temporal boost
Working summaries session-scoped context priority
Semantic semantic_facts (new) permanent high weight

Implementation Sketch

  1. Add MemoryTier enum: Working | Episodic | Semantic
  2. Tag messages table rows with tier + promotion_timestamp
  3. Background sweep (similar to existing autosave/snapshot loop):
    • Compact working → episodic at current summarization_threshold
    • Promote episodic → semantic on Ebbinghaus expiry or after appearance in N+ sessions:
      a. Cluster recent embeddings using cosine similarity threshold (e.g. 0.92)
      b. Merge near-duplicate entries via LLM, strip episodic metadata (timestamp, session_id)
      c. Soft-delete episodic originals after promotion (preserving searchability with decay boost)
    • Promotion signal: a fact appears in N+ sessions without contradiction → stable semantic knowledge
  4. memory_search queries all three tiers with tier-weighted scoring
  5. CLI: /memory promote to trigger manual promotion
  6. TUI: semantic fact count in memory panel

Config:

[memory.tiers]
enabled = true
promotion_min_sessions = 3      # appearances before episodic→semantic promotion
similarity_threshold = 0.92     # cosine threshold for clustering

Integration Points

References

  • arXiv:2512.13956 (AOI)
  • arXiv:2501.11739, arXiv:2512.13564 (memory survey)
  • Zeph crates: zeph-memory (semantic/mod.rs, sqlite/), zeph-core (agent/persistence.rs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Research — medium-high complexitymemoryzeph-memory crate (SQLite)researchResearch-driven improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions