cognee: graph memory for AI agents in five lines of Python
A plain-English guide to cognee — the lightweight, graph-first memory library for AI agents. Sits between mem0 (LLM-managed) and graphiti (Neo4j-heavy). 10-minute install, no external database required to start.
Short version: cognee is a lightweight, graph-first memory library for Python that gives you working knowledge-graph memory in about 5 lines of code. It's the natural middle ground between mem0 (LLM-managed, vector-first) and graphiti (heavier, Neo4j-backed). No external database needed to start — local SQLite/DuckDB works out of the box. 10-minute install, Apache-2.0 licensed. By topoteretes.
What is cognee?
cognee gives your agent a knowledge graph — entities, relations, observations — without forcing you to run Neo4j or spin up managed infrastructure. You write Python. You call cognee.add() with raw text. You call cognee.cognify() to build the graph. You query it. It's probably the simplest "real" graph memory that exists.
Under the hood it uses an LLM to extract entities and relations, then stores them with a vector index for semantic search. For solo developers and small teams, local storage is plenty. When you scale, you swap the backend (Postgres, Qdrant) without rewriting your code.
Who this is for
- Python-capable teams prototyping agent memory.
- Solo developers who want graph semantics without running Neo4j.
- Anyone who finds mem0 too opaque (black-box extraction) and graphiti too heavy (requires Neo4j).
- Builders who want a memory library, not a managed service.
Skip this if
You want visual graph exploration (use graphiti), a managed hosted option (use zep or mem0 cloud), or a non-Python SDK (use supermemory / mem0's TypeScript SDK).
What problem it solves
You want graph-shaped memory — "Amara leads CX at Linea" is two entities and a relation, not a flat text blob — but you don't want to run infrastructure. Most graph databases assume you'll deploy Neo4j or equivalent. That's a lot of ops work for a solo founder.
cognee ships with a local backend that works out of the box. You get the graph semantics (cross-entity queries, structural search) without the infrastructure lift. When you actually need scale, you swap the backend; your code doesn't change.
How to install it (plain English)
- Install.
pip install cognee. - Minimal script. Add a fact, cognify, query:
import cognee await cognee.add("Amara is the CX lead at Linea, effective April 15 2026.") await cognee.cognify() results = await cognee.search("who is the CX lead at Linea?") print(results) - (Optional) Configure storage. By default cognee stores locally. Point it at Postgres, Qdrant, or another backend when you scale via env vars.
- (Optional) Wrap as an MCP server. Community wrappers exist for calling cognee from Claude Code or Cursor.
Full walkthrough: /memory/tools/cognee.
What you can do with it (for a non-technical founder)
If your technical team is evaluating memory libraries:
- Graph memory in a day — a working prototype in hours, not weeks.
- No infrastructure dependency — local SQLite/DuckDB means the team can ship without ops.
- Swappable backend — when usage grows, they migrate to Postgres without rewriting the app.
- Python ecosystem fit — drops into any existing Python agent or tool.
What CLO adds on top
cognee is the structured memory your application queries. Cognition CLO is the pedagogy layer on top that models what your team is retaining from the knowledge that memory surfaces. Build on cognee; layer CLO when you want to know which concepts your humans are quietly forgetting.
FAQ
What's the difference between cognee and graphiti?
Both are graph-first. graphiti is heavier, temporal-aware (first-class time dimension), and assumes Neo4j. cognee is lighter, works locally, and swaps backends. Start with cognee; migrate to graphiti if you need temporal semantics.
Why cognify() as a separate step?
add() is cheap (text in). cognify() is the LLM-heavy graph-construction step. Splitting them lets you batch adds and run one cognify pass per batch, saving tokens.
Is cognee good for RAG?
Yes — cognee can serve as the retrieval layer for a RAG pipeline. Its graph semantics give richer context than a pure vector search.
Can I use it with Claude Code or Cursor?
Yes, via the community MCP wrapper. Check the cognee repo for the current setup path.
How does it compare to mem0?
mem0 is LLM-managed and vector-first — the model decides what's a memory. cognee is graph-first and more explicit — you control the inputs; the cognify step builds structure. Use mem0 for multi-user production; use cognee when you want graph control.
Production-ready?
For single-tenant, Python-backed workloads, yes. For multi-tenant SaaS at scale, mem0 or zep are more battle-tested. Cognee is the right pick for teams who want to own their memory stack.
Ready to install? Full walkthrough at /memory/tools/cognee. Credit to @topoteretes for building and maintaining the library — star the repo if the 5-line API clicks.
Share this post: