Sandbox
@topoteretes/cognee

Python memory platform for agent knowledge graphs

Cognee gives agents persistent long-term memory by turning content into a self-hosted knowledge graph and searchable memory store. It supports remember, recall, improve, and forget flows, plus MCP and plugin integrations for agent tools.

30,628 stars3k forksPythonUpdated 6d ago
Cognee - Knowledge Engine for AI Agent Memory
cognee3.4k views • 6 months ago
Who it's for

Builders who want their agent to keep context, reuse decisions, and recall project knowledge across sessions.

What it delivers

You can stop re-explaining project history and let your agent retrieve durable context from memory.

What it does

Persistent agent memory

Stores facts, decisions, and session lessons so they can be recalled in later runs.

Knowledge graph ingestion

Turns text, code, and other sources into entities, relationships, and searchable chunks.

Session memory and caching

Keeps fast session context and can sync useful lessons into permanent memory.

Hybrid recall

Retrieves context through graph, vector, or code search with automatic routing.

Agent integrations

Provides MCP, plugin, and API entry points for Claude Code, Codex, Cursor, and other clients.

Self-hosted deployment

Runs locally or on your own infrastructure with Docker, Postgres, and deployment templates.

How to get it

  1. 1You can install Cognee with pip, uv, or your preferred Python package manager.
    uv pip install cognee
  2. 2Run
    cognee-cli demo

README

Cognee Logo

Cognee - The Open-Source AI Memory Platform for Agents

Demo . Docs . Learn More · Join Discord · Join r/AIMemory . Community Plugins & Add-ons

GitHub forks GitHub stars GitHub commits GitHub tag Downloads License Contributors Sponsor

topoteretes%2Fcognee | Trendshift

Cognee is the open-source AI memory platform that gives AI agents persistent long-term memory across sessions. Ingest data in any format, build a self-hosted knowledge graph, and let every agent recall, connect, and act with full context

🌐 This README is also available in:
Deutsch | Español | Français | 日本語 | 한국어 | Português | Русский | 中文

Cognee Demo

📄 Read the research paper: Optimizing the Interface Between Knowledge Graphs and LLMs for Complex Reasoning — Markovic et al., 2025

When to use Cognee

  • Build a Company Brain. Bring documentation, conversations, tickets, code, and agent work into shared memory. Help your team and agents connect a decision to the discussion and implementation behind it. Explore Company Brain.
  • Give agents memory across runs. Retain project context, past decisions, fixes, and learned rules. Distill useful session lessons into durable knowledge that another session can retrieve. Connect your agent.
  • Ground agents in your domain. Structure memory around the entities and relationships your application needs, with custom data models and ontologies. Explore ontologies.

Choose your starting point

I want to…Start here
See a memory graph without an API keyBundled demo
Build with text, code, and session memoryPython quickstart
Give an existing agent memoryPlugins and MCP
Run Cognee on my infrastructureDeployment options
Use a managed serviceCognee Cloud

Quickstart

Requires Python 3.10–3.14.

You can install Cognee with pip, uv, or your preferred Python package manager.

uv pip install cognee

Try it without an API key

cognee-cli demo

Step 2: Configure the LLM

import os
os.environ["LLM_API_KEY"] = "YOUR OPENAI_API_KEY"

Alternatively, create a .env file using our template.

The default uses OpenAI for language models and embeddings. Processing and generated answers make provider calls. See installation, other providers, or local Ollama models for other setups.

import cognee
import asyncio


async def main():
    # Store permanently in the knowledge graph (runs add + cognify + improve)
    await cognee.remember("Cognee turns documents into AI memory.")

    # Store in session memory (fast cache, syncs to graph in background)
    await cognee.remember("User prefers detailed explanations.", session_id="chat_1")

    # Query with auto-routing (picks best search strategy automatically)
    results = await cognee.recall("What does Cognee do?")
    for result in results:
        print(result)

    # Query session memory first, fall through to graph if needed
    results = await cognee.recall("What does the user prefer?", session_id="chat_1")
    for result in results:
        print(result)

    # Delete when done
    await cognee.forget(dataset="main_dataset")


if __name__ == '__main__':
    asyncio.run(main())

How Cognee works

Cognee builds connected memory from different sources. Text becomes entities, relationships, and searchable chunks; code becomes a graph of symbols and dependencies. Session distillation curates accepted lessons into permanent memory.

Text, code, and session guidance follow their ingestion paths into persistent Cognee memory

At query time, retrieval selects relevant graph, vector, or code context. Your application can inspect the retrieved evidence and use it to answer a question or continue an agent task.

Recall retrieves a document fact, a code symbol, and a learned release rule for an agent's next task

OperationWhat it doesLearn more
rememberStore content or code in permanent memory, or in a session when a session ID is supplied.Store memory
recallRetrieve context and answers, using automatic routing or a chosen search strategy.Query memory
improveEnrich memory, apply feedback, and bridge session knowledge into the graph.Improve memory
forgetRemove a specific item or dataset.Delete memory

Explore the architecture and session lifecycle.

Connect your agent

Install the Claude Code plugin:

claude plugin marketplace add topoteretes/cognee-integrations
claude plugin install cognee-memory@cognee

or Codex plugin

Make sure to enable hooks:

# ~/.codex/config.toml
[features]
hooks = true
codex plugin marketplace add topoteretes/cognee-integrations --ref main
codex plugin add cognee@cognee

Follow the plugin setup guide to configure local or remote memory.

InterfaceStart here
Claude Code memory pluginInstall and configure the plugin
OpenClaw memory pluginInstall @cognee/cognee-openclaw
Cursor, Cline, and other MCP clientsCognee MCP guide and server README
Python applicationsPython API reference
TypeScript applicationsTypeScript SDK
Rust applicationsCognee-RS
Applications using HTTPREST API reference

Browse the integrations repository for agent frameworks, plugins, and source connectors. Each guide describes its setup and memory capture behavior.

To inspect a local installation in the UI:

cognee-cli -ui

The UI launcher requires Node.js/npm; Docker is needed for its MCP service. See local UI setup.

Explore examples

Deploy Cognee

For a local API demo using a prebuilt image, follow the minimal Docker Compose guide. It includes a persistent-volume configuration and explains the single-user demo settings.

To run the API, UI, and MCP server from a source checkout, clone this repository, enter its directory, copy .env.template to .env, and configure your providers. Then run:

docker compose --profile ui --profile mcp up

The default ports are API 8000, UI 3000, and MCP 8001. For deployment beyond a local demo, configure authentication, persistent storage, and compatible backends using the permissions guide and deployment templates. Cognee Cloud provides the managed option.

Run the Whole Memory Layer on Postgres

Graph memory traditionally means operating a stack — a graph database for relationships, a vector database for embeddings, Redis for sessions, and a relational database for metadata — all deployed, secured, and paid for before an agent remembers anything. In cognee 1.0 you can run the entire memory layer on a single Postgres instance.

⚠️ Warning: Using Postgres as a graph store is currently a released as a demo feature. The production ready feature is available as a licenced product. Use it to demo keeping relational metadata, PGVector, and graph working together

Benchmarks and research

The BEAM evaluation measures conversational memory using synthetic long-context conversations and an LLM judge. The reported runs use Cognee's memory components with benchmark-specific data formatting, prompts, and retrieval configuration.

BEAM contextReported score (0–1)Scope
100K tokens0.79Fixed hybrid retrieval; four evaluation rounds over 20 questions from one held-out conversation.
10M tokens0.67Exploratory result; question-type routing selected and scored on the same question set, averaged over five rounds.

The two settings use different conversations, ingestion models, and retrieval-selection procedures. Read the methodology, models, limitations, and reproduction instructions before comparing these scores with other systems. The report also documents the remaining reproduction gap for the distributed 10M ingestion.

For the research behind Cognee's graph/LLM interface, see Optimizing the Interface Between Knowledge Graphs and LLMs for Complex Reasoning (Markovic et al., 2025).

Latest News

Watch Demo

  • Cognee comes with better incremental load
  • Cognee now supports ingestion of multiple repositories at once
  • Cognee now has better memory usage
  • Cognee now has better conflict resolution
  • Cognee now has ability to call external relational stores
  • Cognee can now ingest from relational databases at scale

Community & Support

Contributing

We welcome contributions from the community! Your input helps make Cognee better for everyone. See CONTRIBUTING.md to get started.

Code of Conduct

We're committed to fostering an inclusive and respectful community. Read our Code of Conduct for guidelines.

Research & Citation

We recently published a research paper on optimizing knowledge graphs for LLM reasoning:

@misc{markovic2025optimizinginterfaceknowledgegraphs,
      title={Optimizing the Interface Between Knowledge Graphs and LLMs for Complex Reasoning},
      author={Vasilije Markovic and Lazar Obradovic and Laszlo Hajdu and Jovan Pavlovic},
      year={2025},
      eprint={2505.24478},
      archivePrefix={arXiv},
      primaryClass={cs.AI},
      url={https://arxiv.org/abs/2505.24478},
}

Files in the repo

Repository payload56 top-level entries
  • .claude
  • .devcontainer
  • .github
  • assets
  • bin
  • catalog
  • cognee
  • cognee_db_workers
  • cognee-frontend
  • cognee-mcp
  • cognee-starter-kit
  • deployment
  • distributed
  • docs
  • evals
  • examples
  • kuzu
  • licenses
  • logs
  • notebooks
  • scripts
  • tests
  • tools
  • working_dir_error_replication
  • .coderabbit.yaml
  • .dockerignore
  • .dockerignore.ci
  • .env.example
  • .env.template
  • .gitattributes
  • .gitguardian.yml
  • .gitignore
  • .mergify.yml
  • .pre-commit-config.yaml
  • AGENTS.md
  • CLAUDE.md
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • CONTRIBUTORS.md
  • DCO.md
  • docker-compose.yml
  • Dockerfile
  • Dockerfile.ci
  • entrypoint.sh
  • LICENSE
  • mise.toml
  • NOTICE.md
  • pr_body.md
  • pyproject.toml
  • README_ko.md
  • README.md
  • RECALL_TOOL_CALLS_PLAN.md
  • SECURITY.md
  • SESSION_POSTGRES_CACHE_PLAN.md
  • slack-app-manifest.yml
  • uv.lock

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More frameworks & sdks

HKUDS/nanobotFrameworks & SDKs

Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps

48k
microsoft/
SkillOpt
microsoft/SkillOptFrameworks & SDKs

SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

17k
omnigent-ai/omnigentFrameworks & SDKs

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.

9.8k
kyegomez/
OpenMythos
kyegomez/OpenMythosFrameworks & SDKs

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

15k
D4Vinci/ScraplingFrameworks & SDKs

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

80k