cognee README

The project's README from github.com/topoteretes/cognee. As one markdown file: README.md.

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

Choose your starting point

I want to… Start here
See a memory graph without an API key Bundled demo
Build with text, code, and session memory Python quickstart
Give an existing agent memory Plugins and MCP
Run Cognee on my infrastructure Deployment options
Use a managed service Cognee 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

Operation What it does Learn more
remember Store content or code in permanent memory, or in a session when a session ID is supplied. Store memory
recall Retrieve context and answers, using automatic routing or a chosen search strategy. Query memory
improve Enrich memory, apply feedback, and bridge session knowledge into the graph. Improve memory
forget Remove 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.

Interface Start here
Claude Code memory plugin Install and configure the plugin
OpenClaw memory plugin Install @cognee/cognee-openclaw
Cursor, Cline, and other MCP clients Cognee MCP guide and server README
Python applications Python API reference
TypeScript applications TypeScript SDK
Rust applications Cognee-RS
Applications using HTTP REST 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 context Reported score (0–1) Scope
100K tokens 0.79 Fixed hybrid retrieval; four evaluation rounds over 20 questions from one held-out conversation.
10M tokens 0.67 Exploratory 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

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},
}

cognee (topoteretes/cognee)

Searching Database…

32.5K ·GitHub
这是什么?Cognee 是一个开源的 AI 记忆平台,能让 AI 智能体跨会话拥有持久的长期记忆,并把文本、代码和对话转化为可查询的知识图谱。
这是我要加到代码里的库,还是只需连接的托管服务?它主要是一个自托管的 Python 库和 API,由你自己运行(通过 pip、Docker 或 MCP 服务器),同时也提供可选的托管服务 Cognee Cloud,供不想自己部署的用户使用。
怎样让它跑起来?用 pip 或 uv 安装(需要 Python 3.10–3.14),将 .env.template 复制为 .env 以配置你的大语言模型和嵌入服务,然后按照 Python 快速入门操作;也可以用 Docker Compose 一起运行 API、UI 和 MCP 服务器。
我需要 OpenAI 的 API 密钥吗,还是可以完全在本地运行?默认情况下,Cognee 调用 OpenAI 的语言模型和嵌入服务,但如果你想避免使用 API 密钥,它也支持本地 Ollama 模型;本地 UI 需要 Node.js/npm,其 MCP 服务则需要 Docker。
我真的能只用 Postgres 跑完整个记忆系统吗?可以,cognee 1.0 支持在同一个 Postgres 实例上运行图、向量和关系型记忆,但这目前是已发布的演示功能,生产可用版本作为单独授权的产品出售。
我的数据会留在自己的基础设施上吗?会。Cognee 以自托管的知识图谱为核心设计,这意味着你部署并掌控记忆存储,而不是默认依赖第三方后端。
Cognee 的核心记忆操作有哪些?Cognee 提供四种操作:remember(存储内容)、recall(通过搜索检索上下文)、improve(应用反馈,并将会话中的经验提升为永久记忆)以及 forget(删除某个条目或数据集)。
智能体如何连接 Cognee 的记忆?现成的插件有 Claude Code 和 Codex 插件,以及 OpenClaw 插件;支持 Cursor、Cline 等 MCP 客户端的 MCP 功能;另外还提供 Python、TypeScript 和 Rust SDK,以及 REST API。
Cognee 的记忆在基准测试中表现如何?在 BEAM 对话记忆基准测试中,Cognee 在 100K tokens 规模、使用固定混合检索时得分 0.79(满分 1);在使用按问题类型路由的探索性测试中,于 10M tokens 规模得分 0.67。
我能把其他工具的记忆迁移到 Cognee 吗?可以,Cognee 能使用 COGX 交换格式,导入来自 Mem0、Letta、Zep 或 Graphiti 的记忆。
What are similar projects?semantica, EverOS, MemOS, LongMemory, MemoryBear, xerj, OpenViking, m_flow
Size
267.3 MB
Stars
32.5K
Age
3y
Commits · 90 Days