Plug'n'play persistent memory for AI agents, powered by Convex
๐ cortexmemory.dev | ๐ docs.cortexmemory.dev
Cortex is currently in the design and early implementation phase. We're building a production-ready memory system for AI agents, and we're doing it in public!
What this means:
- ๐ Architecture and documentation are actively being refined
- ๐ป Core SDK implementation is in progress
- ๐ฏ API design is stabilizing but may still change
- ๐ค Community input is shaping the direction
Want to contribute or follow along?
- ๐ cortexmemory.dev - Official website and project information
- ๐ docs.cortexmemory.dev - Complete documentation and guides
- ๐ฌ GitHub Discussions - Share ideas, ask questions, propose features
- ๐ GitHub Issues - Report bugs, request features, track progress
Cortex brings enterprise-grade persistent memory to any AI agent system. Built on Convex, it provides flexible, scalable memory that works with any LLM or framework.
The Problem We're Solving:
Traditional memory solutions force you to choose between vector databases (Pinecone, Weaviate) or simple storage (Redis), manage complex infrastructure, write custom multi-agent coordination logic, and handle user profiles separately. It's fragmented, complex, and time-consuming.
The Cortex Solution:
A unified memory system that gives you everything in one package - production-ready memory that scales automatically, works with any LLM framework, supports any embedding provider, and requires zero infrastructure management.
Cortex provides a complete memory system for AI agents:
- ๐ง Flexible Memory - Remember anything without hardcoded topics or schemas โ
- ๐ Memory Space Isolation - Flexible boundaries (per user, team, or project) โ
- โพ๏ธ Long-term Persistence - Memories last forever with automatic indexing โ
- โฑ๏ธ Automatic Versioning - Updates preserve history, never lose data (10 versions default) โ
- ๐๏ธ ACID + Vector Hybrid - Immutable conversation source + fast searchable index โ
- ๐ Semantic Search - AI-powered retrieval with multi-strategy fallback โ
- ๐ Vector Embeddings - Optional but preferred, support any dimension (768, 1536, 3072+) โ
- ๐ Context Chains - Hierarchical context sharing across memory spaces โ
- ๐ฅ User Profiles - Rich user context with GDPR cascade deletion โ
- ๐ Access Analytics - Built-in statistics and insights โ
- ๐ฏ Agent Registry - Optional metadata for discovery and cascade cleanup โ
- ๐ Embedding Agnostic - Works with OpenAI, Cohere, local models, or any provider โ
- ๐ธ๏ธ Graph Database Integration - Neo4j/Memgraph support with orphan detection โ
- ๐ง Fact Extraction - LLM-powered fact extraction for 60-90% storage savings โ
- ๐ก๏ธ Governance Policies - Centralized data retention, purging, and compliance (GDPR, HIPAA, SOC2, FINRA) โ
- ๐ MCP Server - Cross-application memory sharing (planned)
- ๐ฌ A2A Communication - Inter-space messaging helpers (planned)
NEW: cortex.governance.* - Centralized control over data retention, purging, and compliance:
- 8 Core Operations: setPolicy, getPolicy, setAgentOverride, getTemplate, enforce, simulate, getComplianceReport, getEnforcementStats
- 4 Compliance Templates: GDPR, HIPAA, SOC2, FINRA (one-click compliance)
- Multi-Layer Governance: Manage retention across conversations, immutable, mutable, and vector layers
- Policy Simulation: Test policies before applying (impact analysis, cost savings)
- Compliance Reporting: Detailed reports with per-layer compliance status
- Flexible Scoping: Organization-wide policies with memory-space overrides
- Automatic Enforcement: Policies enforced on write operations
- Audit Trail: Complete enforcement history and statistics
// Apply GDPR template
const policy = await cortex.governance.getTemplate("GDPR");
await cortex.governance.setPolicy({
...policy,
organizationId: "my-org",
});
// Override for audit agent (unlimited retention)
await cortex.governance.setAgentOverride("audit-agent", {
vector: { retention: { defaultVersions: -1 } },
});
// Simulate policy impact before applying
const impact = await cortex.governance.simulate(newPolicy);
console.log(
`Would save ${impact.storageFreed} MB, $${impact.costSavings}/month`,
);
// Generate compliance report
const report = await cortex.governance.getComplianceReport({
organizationId: "my-org",
period: { start: new Date("2025-01-01"), end: new Date("2025-12-31") },
});Enterprise Value:
- โ One-click GDPR, HIPAA, SOC2, FINRA compliance
- โ Automatic data lifecycle management
- โ Cost optimization insights
- โ Complete audit trails
NEW: memory.rememberStream() - First-class streaming support for AI responses:
- Stream any response format: ReadableStream or AsyncIterable
- Edge runtime compatible: Works in Vercel Edge Functions, Cloudflare Workers
- Zero buffering required: Handles stream consumption internally
- All features supported: Embeddings, facts extraction, graph sync
- Production ready: 28/28 streaming tests + 19/19 edge tests passing
// With Vercel AI SDK streaming
const stream = await generateText({ model: "gpt-5-nano", messages });
const result = await cortex.memory.rememberStream({
memorySpaceId: "agent-1",
conversationId: "conv-123",
userMessage: "What is the weather?",
responseStream: stream, // ReadableStream or AsyncIterable
userId: "user-1",
userName: "Alex",
});
console.log("Full response:", result.fullResponse);
// All memories stored automatically once stream completesEdge Runtime verified: All SDK operations work in edge environments - no Node.js APIs used.
Complete implementation of coordination layer APIs with powerful cascade deletion:
Users API (cortex.users.*) - GDPR Compliance
- User profile management with automatic versioning
- GDPR cascade deletion by userId across all layers
- Works in free SDK (DIY graph) and Cloud Mode (managed + legal guarantees)
- Deletes from: conversations, immutable, mutable, vector, facts, graph
- Transaction-like rollback on failures
- 23/23 tests passing on LOCAL and MANAGED
Agents API (cortex.agents.*) - Optional Registry
- Optional metadata registration for discovery and analytics
- Cascade deletion by participantId across all memory spaces
- Works even if agent was never registered
- Deletes from: conversations, memories, facts, graph
- Graph orphan detection included
- 20/20 tests passing on LOCAL and MANAGED
// GDPR cascade deletion by userId
await cortex.users.delete("user-123", {
cascade: true, // Deletes across ALL layers
verify: true, // Checks for orphaned records
});
// Agent cleanup by participantId
await cortex.agents.unregister("agent-xyz", {
cascade: true, // Deletes across ALL memory spaces
verify: true, // Includes graph orphan detection
});Get started with Cortex in under 5 minutes:
npm create cortex-memoriesThe interactive wizard will guide you through:
- Project Setup - Choose new project or add to existing
- Convex Configuration - Local development, new cloud database, or existing database
- Graph Database - Optional Neo4j/Memgraph integration
- Automatic Setup - Installs dependencies and deploys backend functions
โ
Cortex SDK with TypeScript support
โ
Convex backend functions (deployed automatically)
โ
Environment configuration (.env.local)
โ
Example code to get you started
โ
Optional graph database integration
cd my-cortex-agent # Or whatever name you chose
npm run dev # Terminal 1: Start Convex
npm start # Terminal 2: Run your agentimport { Cortex } from "@cortexmemory/sdk";
const cortex = new Cortex({
convexUrl: process.env.CONVEX_URL!,
});
// Store a memory
await cortex.memory.remember({
memorySpaceId: "my-agent",
conversationId: "conv-1",
userMessage: "I prefer dark mode",
agentResponse: "Got it! I'll remember that.",
userId: "user-123",
userName: "User",
});
// Search your memories
const results = await cortex.memory.search(
"my-agent",
"what are the user's preferences?",
);That's it! Your AI agent now has persistent memory.
cd your-existing-project
npm create cortex-memories
# Select current directory when promptedAdd powerful graph database capabilities to Cortex for advanced relationship queries:
import { Cortex } from "@cortexmemory/sdk";
import { CypherGraphAdapter, initializeGraphSchema } from "@cortexmemory/sdk/graph";
// Setup graph database
const graph = new CypherGraphAdapter();
await graph.connect({ uri: "bolt://localhost:7687", ... });
await initializeGraphSchema(graph);
// Initialize Cortex with graph
const cortex = new Cortex({
convexUrl: process.env.CONVEX_URL!,
graph: { adapter: graph }
});
// Use normally - auto-syncs to graph!
await cortex.memory.remember({
memorySpaceId: "agent-1",
conversationId: "conv-123",
userMessage: "Alice works at Acme Corp using TypeScript",
agentResponse: "Got it!",
userId: "alice",
userName: "Alice"
});
// Graph enrichment provides 2-5x more context:
// - Discovers entity relationships (Alice knows Bob, Bob uses TypeScript)
// - Reconstructs full context chains (parent-child workflows)
// - Traces provenance (memory โ conversation โ context โ user)
// - Enables multi-hop knowledge discoveryWhen to use:
- Deep context chains (5+ levels)
- Knowledge graphs with entity relationships
- Multi-hop reasoning (Alice โ Company โ Bob โ Technology)
- Provenance tracking and audit trails
- Complex multi-agent coordination
Performance: 3.8x faster for deep traversals, <100ms enrichment overhead
See Graph Database Setup Guide for quick start!
Cortex is being designed with two deployment modes:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Application โ
โ (Next.js, Express, LangChain, etc.) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cortex SDK (Open Source) โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโ โ
โ โ Memory โ โ Context โ โ User โ โ
โ โ Operations โ โ Chains โ โ Profiles โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Convex Instance โ
โ โข Convex Cloud (managed) โ
โ โข Self-hosted (local or your infrastructure) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Perfect for: Getting started, prototyping, and self-managed deployments.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Application โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cortex SDK (same code!) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cortex Cloud API โ
โ โข Analytics & Insights โข Team Management โ
โ โข Cost Optimization โข Advanced Features โ
โ โข Migration Tools โข Priority Support โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ (using your Convex credentials)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Convex Instance โ
โ โข Convex Cloud (managed) โ
โ โข Self-hosted (local or your infrastructure) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Perfect for: Production deployments with advanced management and analytics.
- Built on Convex: Leverages Convex's reactive backend for optimal performance
- ACID + Vector Hybrid: Immutable conversation history + searchable memory index (linked via conversationRef)
- Any Convex deployment: Works with Convex Cloud, localhost, or self-hosted infrastructure
- Embedding-agnostic: Optional embeddings from any provider (OpenAI, Cohere, local models)
- Progressive enhancement: Works with raw content (text search) or embeddings (semantic search)
- Hybrid agents: Start simple with string IDs, add structure when needed
- Flexible dimensions: Support for any vector dimension (768, 1536, 3072+)
- Your data, your instance: Whether direct or cloud mode, data lives in your Convex deployment
- Chatbots - Remember user preferences and conversation history
- Multi-agent Systems - Coordinate between specialized agents
- RAG Pipelines - Store and retrieve relevant context for LLM prompts
- Customer Support - Maintain customer context across interactions
- Personal Assistants - Long-term memory of user preferences and habits
- Knowledge Management - Organizational memory across teams
| Feature | Cortex | Pinecone | Weaviate | Redis |
|---|---|---|---|---|
| Vector Search | โ | โ | โ | โ |
| ACID Transactions | โ | โ | โ | โ |
| Real-time Updates | โ | โ | โ | โ |
| Versioning | โ | โ | โ | โ |
| Temporal Queries | โ | โ | โ | โ |
| Serverless | โ | โ | โ | โ |
| Context Chains | โ | โ | โ | โ |
| Agent Management | โ | โ | โ | โ |
| User Profiles | โ | โ | โ | โ |
| Open Source Core | โ | โ | โ | โ |
| Self-Hostable | โ | โ | โ | โ |
| All-in-One | โ | โ | โ | โ |
๐ docs.cortexmemory.dev - Complete documentation, guides, and API reference
- Installation Guide - Multiple installation methods
- Five-Minute Quickstart - Build your first agent
- Core Concepts - Understand the fundamentals
- Configuration - Customize Cortex
- API Reference - Full API documentation
- System Architecture - How it works
- Recipes & Examples - Real-world patterns
- Local Documentation - Repository documentation
We're building Cortex in public and would love your input!
-
GitHub Discussions - Best for:
- ๐ก Sharing feature ideas and use cases
- ๐ค Asking questions about architecture decisions
- ๐ฃ Providing feedback on the API design
- ๐ฏ Discussing roadmap priorities
-
GitHub Issues - Best for:
- ๐ Reporting bugs (when we have code to break!)
- โจ Requesting specific features
- ๐ Tracking development progress
- ๐ Following implementation work
- Share Your Use Case - Tell us how you'd use Cortex in your AI agent system
- Review the Architecture - Check our docs and provide feedback on the design
- Propose Features - What would make Cortex perfect for your needs?
- Test Early Builds - Try out alpha/beta releases and report issues
- Improve Documentation - Help us make the docs clearer and more comprehensive
- Spread the Word - Star the repo, share with others building AI agents
See CONTRIBUTING.md for detailed contribution guidelines.
Current Phase: Foundation (Q4 2025)
- โ Core architecture design
- โ Documentation framework
- ๐ Convex schema implementation
- ๐ Core SDK development
- ๐ Unit test framework
- ๐ Integration tests
Next Phases:
-
Q1 2026: Alpha release (Direct Mode)
- Core memory operations working
- Basic agent management
- Essential documentation
- Developer preview for feedback
-
Q2 2026: Beta release
- Full Direct Mode implementation
- Context chains and user profiles
- Integration examples (LangChain, Vercel AI SDK)
- Production-ready documentation
-
Q3 2026: v1.0 Public Launch
- Stable API
- Comprehensive test coverage
- Performance optimization
- Migration tools
-
Q4 2026: Cloud Mode Preview
- Analytics and insights
- Team management features
- Advanced monitoring
- Enterprise features
Follow our progress:
- Check Project Boards for current work
- Read Development Updates for milestone announcements
- Join Discord for real-time development chat (coming soon)
- Data Isolation: Each agent's memories are completely isolated
- Your Infrastructure: Deploy to your own Convex instance
- No External Calls: Cortex never sends data outside your Convex deployment
- Flexible Access Control: Implement your own auth layer on top
- Open Source Core: Audit the code yourself - full transparency
Cortex SDK uses dual release workflows:
๐ค Automated (Production - recommended):
- Bump version in
package.jsonโ Push tomainโ GitHub Action publishes automatically - Full details: RELEASE-GUIDE.md
๐ป Manual (Beta/hotfix - full control):
- Run
npm run releasefor interactive publishing - See: scripts/release.ps1
Setup: .github/SETUP-AUTOMATED-RELEASES.md
๐ Infinite Context
- Never run out of context again
- Recall from millions of past messages via retrieval
- Up to 99% token reduction vs traditional accumulation
- Works with any LLM (smaller models perform like SOTA with perfect memory)
๐ Hive Mode
- Multiple AI tools share one memory space
- Zero duplication (Cursor + Claude + custom tools)
- Cross-application memory via MCP
- Your memory follows you everywhere
๐ข Enterprise-Ready
- Complete ACID audit trails
- Automatic versioning (temporal queries)
- One-click GDPR cascade deletion
- Governance policies built-in
๐ค Multi-Agent Orchestration
- Context Chains for workflow coordination
- A2A communication protocol
- Hive Mode (shared space) OR Collaboration Mode (separate spaces)
- Flexible isolation models
๐ง Developer Experience
- Single database (Convex - no polyglot complexity)
- Framework-agnostic (LangChain, Vercel AI, custom)
- Embedding-agnostic (OpenAI, Cohere, local models)
- TypeScript-first with full type safety
๐ Unified Architecture
- 4-layer design (ACID + Vector + Facts + Convenience)
- Graph-Lite built-in, native graph DB optional
- Facts extraction (DIY or Cloud auto)
- All data in one place (Convex)
Cortex maintains enterprise-grade security practices:
Automated Security Scanning:
- โ CodeQL - Static analysis for vulnerabilities
- โ Trivy - Dependency vulnerability scanning
- โ Gitleaks - Secret detection
- โ Semgrep - API security & OWASP Top 10
- โ Bandit & Safety - Python security scanning
- โ OpenSSF Scorecard - Supply chain security rating
- โ Dependency Review - Automated PR checks
Supply Chain Transparency:
Socket.dev may flag "network access" in this package. This is expected and safe:
- The SDK requires network access to communicate with Convex (cloud database)
- All network calls go to
*.convex.cloudendpoints only - This is documented, audited, and necessary for core functionality
- See
.socket.dev.ymlfor our security policy
Report Security Issues:
- ๐ Email: [email protected]
- ๐ See SECURITY.md for our security policy
Open Source Core: Apache License 2.0
- The Cortex SDK is and will remain open source
- Free for commercial use
- Includes explicit patent grant and protection
- See LICENSE.md for details
Cortex Cloud: Commercial service (future)
- Optional managed features and analytics
- Free tier planned
- Pay only for advanced features and support
Why Apache 2.0?
- Aligns with Convex (also Apache 2.0)
- Explicit patent protection for users and contributors
- Enterprise-friendly and legally clear
- Same permissiveness as MIT with better legal protections
Cortex is built on the shoulders of giants:
- Convex - The reactive backend platform powering Cortex
- Project Constellation - The original inspiration for this system
- The open source AI community - For pushing the boundaries of what's possible
Cortex was born out of building Project Constellation, an enterprise multi-agent AI system for Microsoft Teams. While building Constellation, we realized the memory system we needed didn't exist - so we're extracting and open-sourcing it as Cortex.
What makes Cortex different:
- Designed for real-world production use (not a prototype)
- Battle-tested patterns from building multi-agent systems
- Built by developers who needed it, for developers who need it
- Focus on developer experience and simplicity
- ๐ Website: cortexmemory.dev
- ๐ Documentation: docs.cortexmemory.dev
- ๐ง Email: [email protected]
- ๐ฌ Discussions: GitHub Discussions
- ๐ Issues: GitHub Issues
- ๐ฆ Twitter: @cortexmemory (coming soon)
โญ Star this repo to follow our progress โญ
Built with โค๏ธ for the AI agent community by Nicholas Geil / Saint Nick LLC
Cortex is in active development. Join Discussions to shape the future of AI agent memory.