Skip to content

Cognee - AI Agent Memory Platform Cheatsheet

Cognee - AI Agent Memory Platform Cheatsheet

Cognee is an open-source AI memory platform that gives agents persistent long-term memory across sessions using a self-hosted knowledge graph. Its defining idea is the ECL pipeline — Extract, Cognify, Load — which ingests documents, conversations, and data from many sources, structures them into a graph of entities and relationships (the “cognify” step), and loads them into graph + vector stores for retrieval. This makes memory an active, queryable layer rather than a flat vector dump.

Installation

MethodCommand
pippip install cognee
uvuv add cognee
With extraspip install "cognee[postgres,neo4j]"
Set an LLM keyexport LLM_API_KEY="sk-..."
Verifypython -c "import cognee; print('ok')"

The ECL Pipeline

StageWhat it does
ExtractIngest raw data from 30+ source types
CognifyBuild a knowledge graph (entities, relationships)
LoadStore into graph + vector databases for retrieval
SearchQuery memory (graph, vector, or hybrid)

Basic Usage

import cognee
import asyncio

async def main():
    # 1) Add data to memory
    await cognee.add("Nick prefers concise, direct answers.")
    await cognee.add(open("notes.md").read())

    # 2) Build the knowledge graph
    await cognee.cognify()

    # 3) Query memory
    results = await cognee.search("What are Nick's preferences?")
    print(results)

asyncio.run(main())
CallDescription
cognee.add(data)Ingest text, files, or structured data
cognee.cognify()Process ingested data into the graph
cognee.search(query, ...)Retrieve from memory
cognee.prune()Reset/clear memory stores

Search Types

TypeReturns
SearchType.GRAPH_COMPLETIONAnswer grounded in the knowledge graph
SearchType.RAG_COMPLETIONClassic vector RAG answer
SearchType.INSIGHTSEntity relationships/insights
SearchType.CHUNKSRaw matching chunks
SearchType.SUMMARIESSummarized results
from cognee import SearchType
res = await cognee.search("connections between X and Y",
                          query_type=SearchType.INSIGHTS)

Data Sources

CategoryExamples
DocumentsPDF, DOCX, Markdown, text
StructuredCSV, JSON, databases
ConversationsChat/message history
CodeSource files/repos

Storage Backends

LayerOptions
Graph storeNetworkX (default), Neo4j, Kuzu
Vector storeLanceDB (default), Qdrant, pgvector, Weaviate
RelationalSQLite (default), PostgreSQL
ConfigSet via environment variables / config

Datasets & Multi-Tenancy

FeatureUse
DatasetsNamespace memory per user/project
cognee.add(data, dataset_name="user-123")Scope ingestion
PermissionsControl access to memory partitions

Common Workflows

# Give an agent durable memory of a user across sessions
await cognee.add(conversation_history, dataset_name="user-42")
await cognee.cognify()
context = await cognee.search("summarize what we know about user-42")
# inject `context` into the agent's prompt

# Build a graph over a document corpus for connect-the-dots questions
for f in docs: await cognee.add(open(f).read())
await cognee.cognify()
await cognee.search("how do these documents relate?",
                    query_type=SearchType.INSIGHTS)

Cognee vs Other Memory Frameworks

AspectCogneeMem0Graphiti
ModelGraph-native (ECL)Multi-tier vector/graph/KVTemporal knowledge graph
StrengthLocal-first graph reasoningConversational personalizationFacts that change over time
Self-hostYesYesYes
Best forPrivacy-critical graph memoryPersonalizationTemporal reasoning

Resources