Cognee: Open-Source AI Memory Platform for Persistent Agent Memory

Aug 12, 2025

Introduction

Building AI agents that remember information across sessions is a persistent challenge for developers, as most LLMs suffer from “goldfish brain”—the inability to retain context beyond a single interaction. Cognee is an open-source AI memory platform that solves this by providing agents with a self-hosted knowledge graph engine, enabling persistent long-term memory. With over 7,000 GitHub stars, Cognee allows developers to transform unstructured data into a reasoning-ready knowledge graph, ensuring that AI agents can recall, connect, and act with full context across multiple sessions.

What Is Cognee?

Cognee is an open-source AI memory platform for AI agents that provides persistent long-term memory across sessions using a self-hosted knowledge graph engine. It is written primarily in Python and licensed under the Apache License 2.0, allowing for flexible deployment on-premises, in Docker, or via Cognee Cloud. By combining vector embeddings, graph reasoning, and cognitive-science-grounded ontology generation, Cognee makes documents both searchable by meaning and connected by relationships that evolve as the knowledge base grows.

The platform implements a modular ECL (Extract, Cognify, Load) pipeline that transforms raw data into a structured semantic layer. This approach moves beyond simple Retrieval-Augmented Generation (RAG) by creating a network of interconnected entities and relationships, mirroring human cognitive processes to reduce hallucinations and improve reasoning capabilities.

Why Cognee Matters

Traditional RAG systems often fail in production because they rely solely on vector similarity, which lacks the structural understanding of how different pieces of information are related. This leads to a failure in multi-hop reasoning—where an agent needs to connect two or more disparate pieces of information to find an answer. Cognee fills this gap by integrating a knowledge graph, allowing agents to traverse relationships and uncover hidden patterns that vector-only approaches cannot detect.

As AI agents move from simple chatbots to autonomous workers, the need for a “company brain” or a persistent personal memory is critical. Cognee provides the infrastructure to unify data from various sources in one place and enable agents with domain-specific knowledge that persists across sessions. This prevents the need for users to repeatedly provide the same information, significantly improving the user experience and the reliability of agentic workflows.

The momentum behind Cognee is evident in its rapid adoption, with thousands of library downloads and hundreds of projects integrating the platform. Its ability to run locally and maintain data privacy makes it an attractive alternative for enterprises that cannot upload sensitive company data to third-party memory services.

Key Features

  • ECL Pipeline (Extract, Cognify, Load): A modular pipeline that splits raw text and media into chunks, uses an LLM to enrich them with a knowledge graph and embeddings, and persists them to vector and graph stores.
  • Graph-Based Reasoning: Enables multi-hop reasoning by allowing agents to traverse interconnected entities and relationships, moving beyond the limitations of simple semantic similarity.
  • Self-Hosted Knowledge Graph: Provides a persistent, self-hosted engine that ensures data privacy and allows for long-term memory across agent sessions.
  • Ontology Grounding: Uses cognitive-science-grounded ontology generation to ensure that the knowledge graph is structured logically and consistently.
  • Multimodal Ingestion: Supports the ingestion of data in any format or structure, including documents, calls, images, and audio transcripts.
  • Agentic User/Tenant Isolation: Ensures that memory is scoped and isolated between different users or tenants, which is essential for multi-tenant AI applications.
  • OTEL Collector and Traceability: Integrates with OpenTelemetry (OTEL) and Langfuse for production-grade tracing, evaluation, and analytics of every pipeline step.
  • Broad LLM Provider Support: Supports OpenAI, Anthropic, Google Gemini, Mistral, Ollama, AWS Bedrock, and any OpenAI-compatible endpoint.

How Cognee Compares

Feature Cognee Traditional RAG Mem0 / Zep
Memory Type Graph + Vector Vector Only Session/User Memory
Reasoning Multi-hop Graph Traversal Semantic Similarity Context Window Management
Deployment Self-Hosted / Cloud Custom Implementation API / Managed
Ontology Support Yes (Cognitive Science) No Partial

Cognee differentiates itself by moving from a simple retrieval system to a cognitive architecture. While traditional RAG is excellent for finding a specific chunk of text, it cannot reason about the relationship between two entities. For example, if a user asks “Who is the manager of the person who wrote the rest of the project’s documentation?”, a vector search would likely fail to find the relationship. Cognee’s graph-based approach allows the agent to traverse the graph from the documentation author to their manager, providing a precise answer.

Compared to other agent memory frameworks like Mem0 or Zep, Cognee focuses more on the structural knowledge of the domain (the “company brain”) rather than just session-based personalization. It provides a more robust infrastructure for building complex, domain-aware agents that can handle gigabytes to terabytes of data with flexible database compatibility.

Getting Started: Installation

Cognee requires Python 3.10 to 3.14 to run. Before installing, ensure you have your preferred Python package manager ready.

Using pip

pip install cognee

Using uv

uv pip install cognee

Using poetry

poetry add cognee

Docker Deployment

Cognee provides prebuilt images on Docker Hub. You can deploy the API server and the MCP server using Docker Compose. Clone the repository and create a .env file based on the template provided in the repo.

git clone https://github.com/topoteretes/cognee 
cd cognee 
cp .env.template .env

After editing the .env file to set your LLM_API_KEY, run:

docker-compose up -d

How to Use Cognee

The core workflow of Cognee is based on the ECL paradigm: Add, Cognify, and Search. This simplifies the process of building a memory layer for your agent in just a few lines of code.

First, you load your data into the system. The add() function handles the loading and chunking of your documents or text. Then, you run the cognify() function, which is the “magic” step where the LLM analyzes the data, extracts entities and relationships, and builds the knowledge graph. Finally, you use the search() function to retrieve context that is both semantically similar and structurally connected.

If you are using a CLI, you can use the cognee-cli to manage your memory and run pipelines. The process is automatic and persistent; once data is cognified, it remains in the graph and vector stores until explicitly forgotten.

Code Examples

Below is a basic “Hello World” example of how to implement Cognee in a Python script. This example demonstrates the basic ECL pipeline.

import cognee, asyncio

async def main():
    # 1. Add data to the memory system
    await cognee.add("Natural language processing (NLP) is an interdisciplinary subfield of computer science.")
    
    # 2. Process the data into a knowledge graph
    await cognee.cognify()
    
    # 3. Search for information
    result = await cognee.search("Tell me about NLP")
    print(result)

asyncio.run(main())

This snippet shows how Cognee handles the ingestion and the graph-building process automatically. The cognify() call triggers the LLM to extract the relationship between “NLP” and “computer science” and store it as a node and edge in the graph.

For more complex scenarios, you can integrate Cognee as a tool for an agent framework like LangGraph. By wrapping the search() function as a tool, the agent can decide when to retrieve its own long-term memory to answer a user’s query.

Advanced Configuration

Cognee allows for deep customization of its memory infrastructure. You can switch the LLM provider and the database backends to suit your enterprise needs.

LLM and Embedding Providers: You can set the LLM_PROVIDER and EMBEDDING_PROVIDER environment variables to switch from the default OpenAI to providers like Anthropic, Google Gemini, Mistral, Ollama, or AWS Bedrock.

Database Backends: Cognee supports multiple vector and graph databases. You can configure the system to use Neo4j, Kuzu, or FalkorDB for graph storage, and ChromaDB, PGVector, or Qdrant for vector storage. This is typically handled through environment variables or a configuration file.

Observability: For production environments, you can integrate Langfuse for tracing and evaluation. By setting LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY, you can monitor every step of the ECL pipeline and evaluate the quality of the retrieval.

Real-World Use Cases

  • Enterprise Knowledge Base: A company can ingest all its internal documentation, Slack messages, and emails into Cognee to create a “Company Brain.” Agents can then answer complex questions about company policy or project history that span multiple documents.
  • Personalized AI Assistants: An assistant can use Cognee to remember a user’s preferences, past interactions, and account details across sessions, providing hyper-personalized service without requiring the user to repeat themselves.
  • Intelligent Research Assistants: A researcher can ingest entire textbooks and research papers into Cognee. The agent can then perform multi-hop reasoning to connect concepts from different papers, synthesizing new insights from a comprehensive knowledge base.
  • Multi-Tenant AI Applications: laas providers canL use Cognee’s tenant isolation to ensure that one user’s memory is strictly separated from another’s, ensuring data privacy and security in a shared infrastructure.

Contributing to Cognee

Cognee is an open-source project that actively encourages community contributions. The project maintains a CONTRIBUTING.md file that outlines the process for submitting bug reports, feature requests, and code changes. Newcomers are encouraged to find issues labeled good first issue to get started.

The project follows a standard GitHub flow: fork the repository, create a feature branch, and submit a pull request. Contributors are also asked to follow the PEP8 style guide and ensure that all new features include corresponding tests to maintain the project’s stability.

Community and Support

Cognee has a growing community of developers and and builders. The primary channel for real-time discussion and support is the official Discord server. For more formal discussions, issue tracking, and feature requests, the GitHub Discussions and Issue Tracker are the recommended paths.

Detailed technical documentation is available at docs.cognee.ai, which includes tutorials, how-to guides, and a detailed API reference. The project also provides a community-managed plugins repository (cognee-community) for add-ons and custom adapters.

Conclusion

Cognee is a powerful solution for developers who need to move beyond the limitations of ephemeral context windows and simple vector search. By integrating a knowledge graph with a vector database, it provides the structural memory necessary for AI agents to perform complex reasoning and maintain continuity across sessions.

While the project is evolving rapidly, it is a strong choice for those building production-grade AI applications that require a high degree of domain awareness and domain-specific knowledge. If you are building an agent that needs to remember, reason, and learn, Cognee is the right tool for the job.

Star the repo, try the quickstart, and join the community to help shape the future of AI agent memory.

What is Cognee and what problem does it solve?

Cognee is an open-source AI memory platform that provides persistent long-term memory for AI agents. It solves the “goldfish brain” problem of LLMs by using a self-hosted knowledge graph engine to store and recall information across sessions.

How do I install Cognee?

You can install Cognee using pip, uv, or poetry. The simplest command is pip install cognee. For a full deployment, you can use the provided Docker Compose files in the GitHub repository.

How does Cognee compare to traditional RAG?

Unlike traditional RAG, which relies on vector similarity, Cognee combines vector search with graph reasoning. This allows agents to perform multi-hop reasoning and understand the structural relationships between different pieces of data.

Can I use Cognee for a multi-tenant AI application?

Yes, Cognee provides agentic user and tenant isolation, ensuring that memory is scoped and separated between different users or tenants in a shared infrastructure.

Which LLM providers does Cognee support?

Cognee supports a wide range of providers, including OpenAI, Anthropic, Google Gemini, Mistral, Ollama, and AWS Bedrock, as well as any OpenAI-compatible endpoint.

What is the license for Cognee?

Cognee is licensed under the Apache License 2.0, which allows for free use, modification, and distribution of the software.

How do I contribute to the Cognee project?

Cognee contributors can submit bug reports, and feature requests via GitHub issues, and submit pull requests for code changes. Newcomers can find issues labeled good first issue to get started.