A second brain for AI agents β episodic, semantic, and procedural memory in one engine.
Quick Start Β· Architecture Β· Why CogDB Β· Roadmap Β· Research
Every AI agent framework treats memory as someone else's problem.
You bolt on a vector database. Then a graph DB for relationships. Then SQLite for structured stuff. Now you're maintaining three backends that don't talk to each other. When two agents update the same fact at the same time, things break silently.
CogDB is a single database that gives AI agents a complete memory system. One install, one interface, one data store.
CogDB unifies the three types of memory that map to how human cognition actually works:
|
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." |
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. |
How to do things Learned workflows captured from successful agent task completions. Reusable templates with success tracking. This memory type basically doesn't exist in any other system. |
| Capability | Mem0 | Zep | Letta | MemPalace | CogDB |
|---|---|---|---|---|---|
| Episodic memory | β | β | β | β | β |
| Semantic / knowledge graph | β | β | β | β | β |
| Procedural memory | β | β | β | ||
| Token-aware retrieval | β | β | β | β | |
| Multi-agent memory scopes | scoped | per-user | shared | per-agent | 4 formal scopes |
| Single unified engine | β | β | β | β | β |
| MCP server | β | β | β | β | β |
| AutoGen + LangGraph adapters | partial | β | β | β | β |
| CrewAI adapter | β | β | β | β | β |
| OpenAI Agents SDK adapter | β | β | β | β | β |
| Semantic Kernel adapter | β | β | β | β | β |
| LlamaIndex adapter | β | β | β | β | β |
| Schema migration tooling | β | β | β | β | β |
Four layers, one engine:
- Layer 1 β Agent Interface. Drop-in adapters for AutoGen, LangGraph, CrewAI, OpenAI Agents SDK, Semantic Kernel, and LlamaIndex. MCP server so any MCP-compatible agent can connect. Native Python SDK.
- Layer 2 β Query Planner. Token-aware retrieval routes queries across stores and packs results into the budget you set. Highest importance first, nothing wasted.
- Layer 3 β Cognitive Pipeline. Encoding, storage, consolidation, retrieval, and decay. Memories don't just sit there β they evolve.
- Layer 4 β Tri-Memory Store. Episodic (vector embeddings), semantic (temporal knowledge graph), procedural (workflow templates). Three stores, one query interface.
pip install git+https://github.com/MuLIAICHI/cogdb.gitfrom cogdb import CognitiveDB
db = CognitiveDB(db_path="./agent_memory")
# π’ Store an episodic memory
db.remember(
"Deployed v2.3 to production. CORS error on /users endpoint.",
agent_id="devops-agent",
importance=0.9,
)
# π’ Store a semantic fact (gets superseded automatically when contradicted)
db.learn(
subject="api_service",
predicate="version",
object="v2.3",
agent_id="devops-agent",
confidence=1.0,
)
# π’ Store a procedural workflow
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 token budget
memories = db.recall(
"How do we fix CORS errors?",
agent_id="devops-agent",
token_budget=500,
)
# π’ Get progressive context (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
memory = CogDBMemory(db_path="./memory")
agent = AssistantAgent(
name="assistant",
memory=[memory],
)Drop-in replacement for AutoGen's basic |
from cogdb.adapters.langgraph import (
CogDBCheckpointer,
CogDBStore,
)
graph = StateGraph(State).compile(
checkpointer=CogDBCheckpointer(...),
store=CogDBStore(...),
)Native |
cogdb-mcp --db-path ./memoryExposes 6 tools β |
from cogdb.adapters.crewai import CogDBCrewAIStorage
memory = CogDBCrewAIStorage(
agent_id="my-crew-agent",
db_path="./memory",
)
# Pass to CrewAI agent via memory_configDrop-in |
from cogdb.adapters.openai_agents import (
CogDBAgentMemory,
make_memory_tools,
)
mem = CogDBAgentMemory(agent_id="my-agent")
tools = make_memory_tools(mem)
# Add tools to your AgentExposes |
from cogdb.adapters.semantic_kernel import CogDBMemoryStore
store = CogDBMemoryStore(
agent_id="sk-agent",
db_path="./memory",
)
# Use as SK MemoryStoreBaseFull async |
from cogdb.adapters.llamaindex import CogDBChatMemory
memory = CogDBChatMemory.from_defaults(
agent_id="li-agent",
db_path="./memory",
)
# Use as LlamaIndex BaseMemory
|
from cogdb.schema.migration import SchemaMigration
from cogdb.schema import FieldSchema
migration = (
SchemaMigration(agent_id="my-agent",
from_version=1, to_version=2)
.add_field("priority", FieldSchema(type="int"), default=0)
.rename_field("tags", "labels")
)
db.migrate_schema(migration)Safe versioned schema evolution with metadata backfill. |
This is the part that took the most iteration. Most memory systems dump a wall of context into the LLM and hope for the best. CogDB does it in tiers:
ββ Token Budget: 500 βββββββββββββββββββββββββββββββββββ
β β
β L0 Identity ~50 tokens [filled] β
β L1 Critical facts ~200 tokens [filled] β
β L2 Task-relevant ~250 tokens [filled] β
β L3 Deep search 0 tokens [skipped] β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Set a budget, CogDB fills it from the top with the highest-importance memories that fit. The agent gets exactly what it needs and nothing it doesn't β which means faster responses, lower API costs, and no context window blowouts.
When you have multiple agents working together, they need different levels of memory access. CogDB has four formal scopes with consistency guarantees:
βββββββββββββββββββββββββββββββββββββββββββββββ
β π’ Organization All agents read β
β βββββββββββββββββββββββββββββββββββββββ β
β β π’ Team Group read-write β β
β β βββββββββββββββββββββββββββββββ β β
β β β π’ Private Single agent β β β
β β βββββββββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββ
β π’ Session Ephemeral, auto-deleted β
βββββββββββββββββββββββββββββββββββββββββββββββ
Contradiction detection runs at write time. Conflict resolution handles concurrent writes. No silent data loss when agents collaborate.
- β
Phase 0 β Python PoC
v0.2.0β Tri-memory engine, pipeline, AutoGen + LangGraph + MCP adapters. - β
Phase 1 β Rust Engine
v0.3.0β Purpose-built storage with HNSW, WAL, crash recovery, PyO3 bindings. - β
Phase 2 β ML Retrieval
v0.4.0β Learned importance model, HNSW rank blending, tokenised procedure search. Suite 1 benchmark: 90.7 / 100. - β Phase 3A β Typed Schemas β Dynamic metadata schemas, per-agent validation, strict/non-strict modes.
- β
Phase 3C β Schema Migration β Versioned add/rename/drop/change_type with metadata backfill.
db.migrate_schema(). - β Adapters expansion β CrewAI, OpenAI Agents SDK, Semantic Kernel, LlamaIndex. 6 framework adapters total.
- π Phase 3B β Metadata Indexing (next) β SQLite indexes on queried metadata keys (requires Rust store changes).
- π Phase 4 β Distributed β Clustered WAL replication, multi-node deployment.
CogDB is grounded in academic research on cognitive architectures, learned database systems, and multi-agent memory:
- CoALA (Sumers, Yao et al., 2024) β Cognitive Architectures for Language Agents
- JEPA (LeCun, 2022) β A Path Towards Autonomous Machine Intelligence
- Learned Index Structures (Kraska et al., 2018) β Neural networks replacing B-Trees
- Multi-Agent Memory Architecture (UCSD, 2026) β Cache coherence for agent memory
Full landscape analysis covering 15+ existing systems β docs/research.md
CogDB is in early development and contributions are welcome across:
- Framework adapters β LlamaIndex plugins, custom integrations
- Benchmarks β LongMemEval, comparison vs Mem0/Zep
- Core engine β Memory consolidation, importance scoring, retrieval
- Research β New memory system analyses, academic paper reviews
See CONTRIBUTING.md to get started.
MIT β see LICENSE.
If you use CogDB in research or production:
@software{cogdb2026,
title = {CogDB: A Cognitive Database for AI Agents},
author = {Mustapha Liaichi},
year = {2026},
url = {https://github.com/MuLIAICHI/cogdb}
}Built by Mustapha Liaichi Β· AYAutomate
If CogDB saves you from stitching together three databases, β the repo.
