v0.4.0 · 90.7/100 on tri-memory benchmark

A Second Brain
for AI Agents

The only database that gives AI agents episodic, semantic, and procedural memory — all in one engine.

quickstart.py
from cogdb import CognitiveDB

db = CognitiveDB(db_path="./agent_memory")

# Store an episodic memory
db.remember("Deployed v2.3. CORS error on /users.", agent_id="devops", importance=0.9)

# Store a fact (auto-supersedes contradictions)
db.learn(subject="api", predicate="version", object="v2.3", agent_id="devops")

# Store a workflow
db.learn_procedure(name="fix_cors", steps=[...], agent_id="devops")

# Recall with a 500-token budget — nothing wasted
memories = db.recall("How do we fix CORS errors?", agent_id="devops", token_budget=500)

Every AI agent framework treats memory
as someone else's problem.

You bolt on a vector DB. Then a graph DB. Then SQLite. Now you're maintaining three backends that don't talk to each other — and silent data loss happens at every concurrent write.

⚠️

Three backends, zero coordination

Vector DB + graph DB + SQLite — maintained separately, queried separately, breaking separately. Every search requires three round-trips you stitched together by hand.

💥

Context window blowouts

No token management means every recall dumps a wall of context into the LLM and hopes for the best. Your agent burns the entire budget on memories from last week.

🔇

Silent data loss in multi-agent systems

Concurrent agent writes with no conflict resolution. Facts overwrite each other. Two agents disagree about the same fact. Nobody notices until production breaks.

One engine. Three memory types.
Zero glue code.

CogDB unifies the three types of memory that map to how cognition actually works. One install, one API, one store.

🟢
Episodic

What happened

Timestamped records of agent interactions, observations, and tool calls. Stored as vector embeddings with full metadata. Agents search by similarity — "find me situations like this one."

🟢
Semantic

What is known

A temporal knowledge graph where facts have lifecycles. Facts get superseded automatically when newer ones contradict them. Confidence scores, validity windows, provenance links — all built in.

🟢
Procedural ✦ unique to CogDB

How to do things

Learned workflows captured from successful agent task completions. Reusable templates with EMA success tracking. This memory type basically doesn't exist in any other system.

Why CogDB

Most memory systems bolt on vector search as an afterthought. CogDB was designed from scratch for the full cognitive stack.

Capability Mem0 Zep Letta MemPalace CogDB
Episodic memory
Semantic / knowledge graph
Procedural memory ⚠️⚠️
Token-aware retrieval ⚠️
Multi-agent memory scopes scopedper-usersharedper-agent4 formal scopes
Single unified engine
MCP server built-in
AutoGen + LangGraph adapterspartial
CrewAI adapter
OpenAI Agents SDK adapter
Semantic Kernel adapter
LlamaIndex adapter
Schema migration tooling
90.7
/ 100 · Tri-Memory Retrieval Benchmark

Suite 1 measures episodic + semantic + procedural recall quality across a mixed workload. Score improved from 87.9 → 90.7 with the learned ImportanceModel (Ridge regression). 140/140 tests pass.

94.6
Episodic + Procedural
87.3
Semantic + Episodic
100%
Consistency score
~830
Write ops/s
~1100
Search ops/s
140/140
Tests passing

Stop drowning your LLM in irrelevant memories.

Most memory systems dump everything and hope the LLM figures it out. CogDB fills your token budget from the top with the highest-importance memories that fit — and stops the moment the budget is spent.

Faster responses. Lower API costs. No context window blowouts. Set a budget and forget about it.

Budget: 500 tokens
L0
Identity
Always included
~50 tok
L1
Critical facts
Included · 300 remaining
~200 tok
L2
Task-relevant
Included · 50 remaining
~250 tok
L3
Deep search
Budget exhausted — skipped
0 tok

Works with every major AI framework

Drop-in adapters — not wrappers. Native protocol implementations for each framework.

Batteries included, no boilerplate.

From zero to a working tri-memory agent in 30 lines. Framework adapters are single-file drop-ins.

from cogdb import CognitiveDB

db = CognitiveDB(db_path="./agent_memory")

# ─── Episodic: timestamped events with vector search ───
db.remember(
    "Deployed v2.3 to production. CORS error on /users endpoint.",
    agent_id="devops-agent",
    importance=0.9,
)

# ─── Semantic: facts with auto-supersession ───
db.learn(
    subject="api_service", predicate="version", object="v2.3",
    agent_id="devops-agent", confidence=1.0,
)

# ─── Procedural: reusable learned workflows ───
db.learn_procedure(
    name="fix_cors_error",
    steps=[
        {"action": "check_nginx_config", "tool": "cat /etc/nginx/conf.d/api.conf"},
        {"action": "add_cors_headers",   "tool": "sed"},
        {"action": "reload_nginx",       "tool": "systemctl reload nginx"},
        {"action": "verify",             "tool": "curl -I"},
    ],
    agent_id="devops-agent",
    applicable_contexts=["cors", "nginx", "api"],
)

# ─── Recall with a 500-token budget ───
memories = db.recall(
    "How do we fix CORS errors?",
    agent_id="devops-agent",
    token_budget=500,
)

# ─── Progressive context loading (L0 → L3) ───
context = db.get_context(
    agent_id="devops-agent", level=2,
    task_hint="API gateway returning 403 on preflight",
    token_budget=800,
)
from cogdb.adapters.autogen import CogDBMemory
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient

# Drop-in replacement for AutoGen's basic ListMemory
memory = CogDBMemory(db_path="./agent_memory")

agent = AssistantAgent(
    name="assistant",
    model_client=OpenAIChatCompletionClient(model="gpt-4o"),
    memory=[memory],
)

# Memories persist across sessions automatically
# Episodic + semantic + procedural — all three memory types available


# ─── LangGraph ───
from cogdb.adapters.langgraph import CogDBCheckpointer, CogDBStore
from langgraph.graph import StateGraph

graph = StateGraph(State).compile(
    checkpointer=CogDBCheckpointer(db_path="./memory"),
    store=CogDBStore(db_path="./memory"),
)

# ─── MCP server (Claude Code, Cursor, Windsurf) ───
# cogdb-mcp --db-path ./memory
# Exposes: remember, recall, learn, learn_procedure, get_context, forget

Four layers, one engine.

A Rust storage core behind a clean Python API. Every layer is independently testable and replaceable.

┌─────────────────────────────────────────────────────────────────────────┐
  Layer 1 — Agent Interface                                              
  AutoGen · LangGraph · CrewAI · OpenAI Agents · Semantic Kernel         
  LlamaIndex · MCP server (cogdb-mcp) · Native Python SDK                
└────────────────────────────────────┬────────────────────────────────────┘
                                     
┌────────────────────────────────────▼────────────────────────────────────┐
  Layer 2 — Query Planner                                                 
  Token-aware retrieval · Store routing · ImportanceModel (Ridge)         
  L0 → L3 progressive loading · HNSW rank blending                       
└────────────────────────────────────┬────────────────────────────────────┘
                                     
┌────────────────────────────────────▼────────────────────────────────────┐
  Layer 3 — Cognitive Pipeline                                            
  Encoder (sentence-transformers) · Consolidator · Decay (EMA)            
  Schema validation · Migration · SPO extraction                          
└────────────────────────────────────┬────────────────────────────────────┘
                                     
┌────────────────────────────────────▼────────────────────────────────────┐
  Layer 4 — Tri-Memory Store  (Rust · cogdb_engine · PyO3)              
                                                                         
   Episodic           Semantic              Procedural                  
   HNSW vectors      petgraph DiGraph       SQLite + WAL fence           
   SQLite + WAL      SQLite + WAL           EMA success rate             
   Scope filters     Auto-supersession      Tokenised retrieval          
└─────────────────────────────────────────────────────────────────────────┘
      

Everything you need.
Nothing you don't.

🦀

Rust storage engine

Purpose-built HNSW vector index, WAL crash recovery, and petgraph knowledge graph — all behind a clean Python API. No external vector DB required.

🧠

Learned importance model

Ridge regression on access patterns ranks memories by relevance. Trained offline, runs locally. No external API key required — ever.

🔒

4-scope multi-agent isolation

Private, team, org, and session scopes with contradiction detection at write time. Scope enforcement happens in Rust — no unguarded code path.

🔄

Schema migration

Versioned add / rename / drop / change_type with metadata backfill. db.migrate_schema() keeps data consistent across schema changes without data loss.

📡

MCP server built-in

cogdb-mcp --db-path ./memory exposes 6 tools to any MCP-compatible agent. Claude Code, Cursor, Windsurf, and more — zero configuration.

Zero cold-start overhead

Singleton engine per db_path. No connection pools, no warmup, no daemon. Just import and call. ~1.2 ms write, ~0.9 ms search — excluding encoding.