Memori: The Open-Source Memory Engine Revolutionizing AI Context Awareness

The Memory Problem in Modern AI Systems

Imagine working with an AI assistant that forgets your project details between conversations. Or a multi-agent system where each component operates in isolation without shared context. This is the reality of today’s large language models (LLMs) – brilliant but forgetful. Memori solves this fundamental limitation by providing AI systems with human-like memory capabilities.

Developed as an open-source solution, Memori acts as a “second memory” for all your LLM workflows, enabling true context awareness without repetitive explanations. Whether you’re building chatbots, multi-agent systems, or complex AI workflows, Memori ensures your AI remembers what matters.

Core Architecture: Dual-Mode Memory System

🧠 Conscious Mode: Short-Term Working Memory

memori = Memori(conscious_ingest=True)  # Enable short-term memory

This mode mimics human working memory by retaining crucial information for immediate access:

  • Identity recognition: Your name, role, and core preferences
  • Active project context: Current work priorities and goals
  • Technical preferences: Coding styles, framework choices
  • Key relationships: Frequent collaborators and stakeholders

Just like you remember a colleague’s coffee order, Memori ensures AI retains your technical preferences across sessions.

🔍 Auto Mode: Dynamic Context Retrieval

memori = Memori(auto_ingest=True)  # Enable intelligent search

This advanced retrieval system works behind the scenes:

  1. Analyzes each user query for underlying context needs
  2. Searches the entire memory database
  3. Injects 3-5 most relevant memory snippets
  4. Optimizes performance through caching and async processing

⚡ Hybrid Mode: Best of Both Worlds

# Combine both memory systems
memori = Memori(
    conscious_ingest=True,  
    auto_ingest=True
)
Memory Mode Activation Trigger Memory Capacity Use Cases
Conscious Mode Session initialization 5-10 key items Identity, preferences, active projects
Auto Mode Every user query 3-5 contextual items Technical problem-solving, deep analysis
Hybrid Mode Both initialization and queries Combined benefits Complex workflows, multi-session projects

Technical Architecture: Three-Layer Processing

1. Memory Processing Core

from memori import MemoryProcessor
processor = MemoryProcessor()
processor.analyze(conversation_text)  # Structured memory extraction

Utilizes Pydantic for robust data handling:

  • Entity extraction: Identifies people, technologies, projects
  • Intelligent categorization: Classifies memories as facts, preferences, or skills
  • Data validation: Ensures type-safe memory storage

2. Conscious Agent

conscious_agent = ConsciousAgent()
conscious_agent.promote_memories()  # Elevates important memories

Operates periodically (default: every 6 hours):

  1. Scans long-term memory repositories
  2. Identifies frequently referenced information
  3. Promotes essentials to short-term memory
  4. Builds entity relationship maps

3. Retrieval Agent

retriever = RetrieverAgent()
context = retriever.fetch("Python async patterns")  # Context-aware fetching

Implements advanced query processing:

  • Semantic query understanding
  • Memory relevance scoring
  • Multi-path retrieval
  • Intelligent result ranking

Getting Started in 5 Minutes

Installation & Setup

pip install memorisdk  # Install core library

Configuration file (memori.json):

{
  "database": {
    "connection_string": "sqlite:///memory.db"
  },
  "agents": {
    "openai_api_key": "your-api-key-here",
    "conscious_ingest": true
  }
}

Basic Implementation

from memori import Memori
from openai import OpenAI

# Initialize memory engine
memori = Memori(config_path="memori.json")  
memori.enable()  # Activate automatic recording

# First conversation - establishing context
client = OpenAI()
response1 = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Building Flask e-commerce platform"}]
)

# Second conversation - automatic context recall
response2 = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "How implement payment gateway?"}]
)
# AI automatically recalls Flask project context

Supported Databases

Database Type Connection Example Use Case
SQLite sqlite:///memory.db Local development & testing
PostgreSQL postgresql://user:pass@localhost/memori Production deployments
MySQL mysql://user:pass@localhost:3306/memdb Enterprise systems

Advanced Implementation Scenarios

Custom Memory Tools

from memori.tools import create_memory_tool

# Create memory query tool
memory_tool = create_memory_tool(memori)

# LangChain integration example
from langchain.agents import AgentExecutor
agent = AgentExecutor(tools=[memory_tool])
agent.run("What database solved high-concurrency last year?")

Multi-Agent Memory Sharing

# CrewAI agents with shared memory
from crewai import Crew, Agent, Task

developer = Agent(
    role='Backend Developer',
    memory=memori  # Shared memory instance
)

reviewer = Agent(
    role='Code Reviewer',
    memory=memori  # Same memory instance
)

Memory Analytics

# Generate memory insights
stats = memori.get_memory_stats()
print(f"Preference distribution: {stats['preferences_distribution']}")
print(f"Top technical skills: {stats['top_skills']}")

# Export knowledge graph
graph = memori.export_kg()
graph.render("memory_relationships.png")

Real-World Applications

Personalized Development Assistant

# Memory-driven code generation
context = memori.retrieve_context("User preferences")
if "prefers concise code" in context:
    generate_minimalist_code()
elif "requires detailed comments" in context:
    generate_documented_code()

Cross-Session Context Maintenance

User: Need Stripe payment integration
[Three days later]
User: Payment status?
AI: Your Stripe integration in PR#42 passes all tests - ready for deployment.

Team Knowledge Transfer

# Onboard new developers with team knowledge
onboarding_memori = Memori()
onboarding_memori.load_team_knowledge("web_team")
# Contains coding standards, framework preferences, etc.

Technical Deep Dive

Memory Storage Architecture

-- Core database schema
CREATE TABLE short_term_memory (
    id INTEGER PRIMARY KEY,
    content TEXT NOT NULL,
    category VARCHAR(32),  -- fact/preference/skill/rule
    expiration TIMESTAMP
);

CREATE TABLE memory_relationships (
    source_id INTEGER,
    target_id INTEGER,
    relation_type VARCHAR(64)
);

Intelligent Retrieval Workflow

graph TD
    A[User Query] --> B{Memory Trigger}
    B -->|New Session| C[Conscious Mode Activation]
    B -->|Ongoing Conversation| D[Auto Mode Activation]
    C --> E[Load Short-Term Memories]
    D --> F[Generate Search Keywords]
    F --> G[Multi-Path Retrieval]
    G --> H[Relevance Ranking]
    H --> I[Top 5 Memory Injection]

Performance Optimization

  1. Layered Caching:

    • Hot memory LRU caching
    • Query result TTL caching
  2. Asynchronous Processing:

    • Background memory analysis
    • Non-blocking I/O operations
  3. Batch Processing:

    • Bulk conversation ingestion
    • Scheduled memory updates

Framework Integration Ecosystem

Framework Integration Method Key Features
LangChain MemoriMemory component Direct replacement for memory modules
CrewAI Shared memory instances Cross-agent knowledge continuity
AutoGen Memory decorators Automatic multi-agent conversation logging
Haystack Memory retrievers Enhanced RAG context

Frequently Asked Questions

Where is memory stored? Is it secure?

Memori stores all data in your specified database (SQLite, PostgreSQL, or MySQL). The system doesn’t transmit any data externally, ensuring complete privacy.

Does Memori increase API costs significantly?

Conscious mode adds minimal overhead (one-time per session). Auto mode’s intelligent retrieval typically reduces conversation length by 30%+, offsetting any additional costs.

What LLMs does Memori support?

Memori works with any LLM platform:

  • OpenAI’s GPT models
  • Anthropic Claude
  • Local LLMs (LLaMA, Mistral)
  • Cloud providers (Azure, AWS, GCP)
  • Any API-compatible model

How can I manage stored memories?

Use the management API:

memori.forget("old_project_details")  # Remove specific memory
memori.set_memory_ttl(48)  # Set 48-hour memory expiration
memori.disable_category("preferences")  # Block preference storage

Enterprise Implementation Guide

Conscious Mode Optimization

# Production-grade configuration
Memori(
    conscious_top_k=7,           # Maintain 7 core memories
    conscious_refresh_hours=12,  # Refresh twice daily
    essential_categories=["identity", "active_projects"]
)

Scalable Deployment Architecture

graph LR
    A[Client Applications] --> B[Memory Proxy Layer]
    B --> C{Memory Type Router}
    C -->|Short-Term| D[Redis Cluster]
    C -->|Long-Term| E[PostgreSQL HA]
    B --> F[Analytics Nodes]

Critical Implementation Practices

  1. Memory Optimization:

    memori.set_max_injection(5)  # Limit context injection
    
  2. Sensitive Data Handling:

    memori.add_filter(r"\d{3}-\d{2}-\d{4}")  # Filter SSN patterns
    
  3. Compliance Auditing:

    memori.audit().export_report("compliance_Q3.pdf")
    

Conclusion: The Future of Context-Aware AI

Memori fundamentally transforms how AI systems handle context by:

  1. Providing human-like short-term recall capabilities
  2. Enabling intelligent long-term context retrieval
  3. Maintaining consistent personality and preferences
  4. Reducing repetitive explanations in conversations

Whether you’re developing personal AI assistants or enterprise multi-agent systems, Memori delivers the missing context layer that enables truly intelligent interactions.

“Just as writing revolutionized human knowledge preservation, Memori represents the next evolution in machine intelligence”

https://memori.gibsonai.com/docs | https://www.gibsonai.com/discord


Memori is open-source software available under MIT license, compatible with Python 3.8+ environments