A second brain for AI agents
One database gives AI agents episodic, semantic, and procedural memory in a single engine. One install, one interface, one store.
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 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 plus graph DB plus SQLite. Maintained separately, queried separately, breaking separately. Every search needs 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 whole 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 and nobody notices until production breaks.
One engine. Three memory types.
CogDB unifies the three types of memory that map to how cognition actually works. One install, one API, one store.
What happened
Timestamped events, vector-searchable
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.
What is known
A temporal knowledge graph
Facts have lifecycles. Newer facts supersede older ones automatically when they contradict. Confidence scores, validity windows, and provenance links are built in.
How to do things
Learned, reusable workflows
Templates captured from successful task completions, with EMA success tracking. The agent gets better at recurring tasks without you reprogramming it.
Unique to CogDBWhy 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 | partial | no | partial | no | yes |
| Token-aware retrieval | no | no | no | partial | yes |
| Multi-agent memory scopes | scoped | per-user | shared | per-agent | 4 scopes |
| Single unified engine | no | no | no | no | yes |
| MCP server built in | no | no | no | ✓ | yes |
| AutoGen + LangGraph adapters | partial | no | no | no | yes |
| CrewAI adapter | no | no | no | no | yes |
| OpenAI Agents SDK adapter | no | no | no | no | yes |
| Semantic Kernel adapter | no | no | no | no | yes |
| LlamaIndex adapter | no | no | no | no | yes |
| Schema migration tooling | no | no | no | no | yes |
Suite 1 measures episodic, semantic, and procedural recall quality across a mixed workload. The score climbed from 87.9 to 90.7 with the learned ImportanceModel (Ridge regression). 140 of 140 tests pass.
Stop drowning your LLM in irrelevant memories.
Most 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, then stops the moment the budget is spent.
Faster responses. Lower API costs. No context-window blowouts. Set a budget and forget about it.
Works with every major 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 about 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 to 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, and procedural, all three 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 to 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
A purpose-built HNSW vector index, WAL crash recovery, and a 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.
4-scope multi-agent isolation
Private, team, org, and session scopes with contradiction detection at write time. Enforcement happens in Rust.
Schema migration
Versioned add, rename, drop, and change_type with metadata backfill. db.migrate_schema() keeps data consistent.
MCP server built in
cogdb-mcp exposes 6 tools to any MCP-compatible agent. Claude Code, Cursor, Windsurf.
Zero cold-start overhead
Singleton engine per db_path. No connection pools, no warmup, no daemon. Just import and call.