Cortex Memory

RAG & Memory 💻 Python ⚖️ MIT 🔴 No recent commits
99 stars

Cortex is a memory system for AI agents that stores, retrieves, and evolves information over time, inspired by human cognitive architecture with dual-tier memory (STM/LTM) and intelligent evolution. It solves the problem of agents lacking persistent, context-aware memory, and is for developers building AI agents or applications that need long-term memory capabilities.

✨ Key features

  • Cognitive architecture with fast STM and persistent LTM
  • Smart evolution: memories connect, merge, and develop relationships
  • Smart collections for context-aware categorization
  • Temporal awareness with customizable recency weighting
  • Hybrid retrieval combining global and domain-aware search
  • Multi-user support with isolation by user and session

🎯 Use cases

  • Building AI assistants that remember user preferences over time
  • Creating agents that recall past decisions and discussions
  • Implementing context-aware search in chat applications
  • Managing user-specific memory in multi-user systems
  • Enhancing LLM applications with long-term memory

📦 Installation

🧰 Requirements: Python 3.11+, Poetry, 4GB+ RAM, OpenAI API key or Ollama URI, and a running ChromaDB server.

git clone https://github.com/prem-research/cortex.git
cd cortex
poetry install
Set your API key
echo "OPENAI_API_KEY=your_key_here" > .env

ChromaDB Server Setup

Cortex requires a persistent ChromaDB server for vector storage. Start it locally:

Install ChromaDB (if not already installed)
poetry add chromadb
Start ChromaDB server locally
poetry run chroma run --host localhost --port 8003
Or using Docker
docker run -p 8000:8000 chromadb/chroma:latest

Note: Keep the ChromaDB server running while using Cortex. Data persists automatically across sessions.

🚀 Usage

from cortex.memory_system import AgenticMemorySystem
from dotenv import load_dotenv
load_dotenv(".env")

# Initialize with your OpenAI key
memory = AgenticMemorySystem(
    api_key=os.getenv("OPENAI_API_KEY"),
    enable_smart_collections=False,
)

# Store memories (auto-analyzes content for keywords, context, tags)
memory.add_note("User prefers morning meetings and uses VS Code")

# Search with context awareness
results = memory.search("What editor does the user like?")
print(results[0]['content'])  # "User prefers morning meetings and uses VS Code"

❓ FAQ

What are the system requirements?

Python 3.11+, Poetry, 4GB+ RAM, and an OpenAI API key or Ollama URI. You also need a running ChromaDB server.

How do I start the ChromaDB server?

You can start it locally with poetry run chroma run --host localhost --port 8003 or using Docker with docker run -p 8000:8000 chromadb/chroma:latest.

Can I use Cortex with self-hosted LLMs?

Yes, it works with Ollama or any LLM/embedding backend, not just OpenAI.

How does temporal weighting work?

You can set a temporal_weight parameter (0 to 1) in search to balance recency vs semantic relevance. Higher values give more weight to recent memories.

📊 Repository

Stars★ 99
Forks🍴 10
Open issues🐛 0
Last commit🕒 Feb 10, 2026
Created📅 Apr 2025
Language💻 Python
License⚖️ MIT

🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.