跳到正文
cccskills
免费在 GitHub 公开

cognee-forget

Find and remove stored content from cognee using its SDK, HTTP API, or CLI. Inspect documents before deletion, choose document or dataset removal, or keep raw files while clearing derived graph relationships and search vectors.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Use when removing data from cognee memory with forget() in the SDK, HTTP API, or CLI — finding which dataset and document hold the content to delete (listing datasets and data items, reading raw content), choosing between deleting one document, a whole dataset, or only the graph/vector memory, and doing it safely.

查看安装方法

适用场景

  • Find and delete a specific stored document
  • Remove an entire dataset
  • Clear derived memory while keeping original files
  • Inspect document contents before deletion

包含的文件(1)

  • SKILL.md7.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Remove data with forget()

forget() is cognee's one deletion API. It removes one document, a whole dataset, or only the derived memory (graph + vectors) while keeping the raw files. Deletion cannot be undone, so the workflow is always find, read, confirm, then delete.

Hard limits for agents

  • Delete only what the user asked to forget. Identify it by reading the content first; never guess from a file name alone.
  • Confirm the exact items with the user before deleting, unless they already named exact ids.
  • The widest deletion you may run is forget(everything=True), and only when the user explicitly asks to wipe all of their memory. Never use any other reset or wipe mechanism to delete data.

Use it

1. Find the dataset

import cognee

datasets = await cognee.datasets.list_datasets()  # datasets the user can read
for ds in datasets:
    print(ds.id, ds.name)

HTTP: GET /api/v1/datasets. CLI: cognee-cli datasets list.

2. List its documents

items = await cognee.datasets.list_data(dataset_id)  # all Data rows, oldest first
for item in items:
    print(item.id, item.name, item.extension, item.created_at)

HTTP: GET /api/v1/datasets/{dataset_id}/data?limit=100&offset=0 (limit up to 1000; GET .../data/count for the total; example: examples/python/dataset_data_pagination.py). CLI: cognee-cli datasets data <dataset_uuid>.

Each item has id, name, created_at, extension, mime_type, raw_data_location, dataset_id, label, external_metadata (including any node_set), and data_size.

3. Read the content before deciding

Names are often text_<hash>.txt, so read the content to find what the user means.

  • HTTP: GET /api/v1/datasets/{dataset_id}/data/{data_id}/raw returns the stored file (404 if it is gone).
  • SDK: there is no "get raw" helper; open the stored location:
from cognee.infrastructure.files.utils.open_data_file import open_data_file

async with open_data_file(item.raw_data_location, mode="rb") as f:
    preview = f.read(2000).decode("utf-8", errors="replace")

Judge matches by meaning, not only by keywords, and show the user the candidates (name + a short preview) before deleting.

4. Delete

GoalCallWhat remains
One documentforget(data_id=..., dataset_id=...) (or dataset="name")Nothing of that document; shared entities stay while another document still references them
A whole datasetforget(dataset="name") or forget(dataset_id=...)The dataset is deleted outright: the record, its data rows, graph and vector stores, and attributed sessions
Rebuild a dataset's graph laterforget(dataset="name", memory_only=True)Raw files and data rows; graph, vectors, sessions and pipeline status are reset, so the data can be re-processed
One document's memory onlyforget(dataset="name", data_id=..., memory_only=True)That document's raw file and row
Every dataset the user can deleteforget(everything=True)Nothing, in any dataset the user has delete on in the current tenant (shared ones included). Only on explicit request (see the hard limits)

Return values: {"data_id", "dataset_id", "status"} for a document, {"dataset_id", "status"} for a dataset (plus data_records_reset with memory_only), {"datasets_removed", "status"} for everything (datasets_removed counts the datasets the user can read, not the delete set).

HTTP: POST /api/v1/forget with a JSON body; camelCase and snake_case keys both work: {"datasetId": "...", "dataId": "..."}, {"dataset": "name", "memoryOnly": true}, {"everything": true}. Invalid combinations return 422.

CLI: cognee-cli forget --dataset NAME | --dataset-id UUID [--data-id UUID] [--memory-only], or --everything / --all. The CLI does not ask for confirmation; confirm with the user first.

Pitfalls

  • A data_id that is not in the dataset returns success and deletes nothing. The delete path treats an unknown id as a custom-graph-model delete. Always take the id from list_data for that same dataset, and check it is still listed afterwards if it matters.
  • Pass either dataset or dataset_id, not both (ValueError). data_id and memory_only both need a dataset.
  • memory_only is ignored when everything=True in the SDK (the CLI rejects the combination). everything=True always deletes everything.
  • Not found and not allowed look the same. An unknown dataset name and one the user cannot delete both raise DatasetNotFoundError. Deleting needs the delete permission on the dataset (see the cognee-permissions skill). everything=True deletes every dataset the user has delete permission on in the current tenant, including datasets shared to them with delete rights, not only the ones they own.
  • Sessions that cited deleted data are invalidated so recall stops returning answers built on it. Agent-trace entries are not invalidated.
  • Changing a document is not a delete. To replace a document's content, use cognee.update(data_id=..., data=..., dataset_id=...), which keeps its id and re-extracts only the changed parts.
  • cognee.delete() is deprecated; use forget().

How it works

forget() resolves the dataset with the delete permission, then:

  • One document → datasets.delete_data(): takes the dataset lock, deletes the graph nodes and edges the document owns, the matching vectors and edge evidence, invalidates sessions that cited them, then deletes the Data row. Ownership is tracked per document (source-refs on graph elements), so an entity shared by two documents survives until both are deleted. Raw files are reference-counted by storage location.
  • A dataset → datasets.empty_dataset().
  • memory_only → drops the dataset's graph/vector memory and resets its pipeline status, leaving raw data for a rebuild.
  • everything → datasets.delete_all() over every dataset the user has delete on in the current tenant, plus a full prune of the session cache (when caching or usage logging is on). This wipes every user's sessions (Redis FLUSHDB / the whole fs cache / all SQL cache tables), not just this user's.

Key files:

  • cognee/api/v1/forget/forget.py (SDK), routers/get_forget_router.py (HTTP), cognee/cli/commands/forget_command.py (CLI)
  • cognee/api/v1/datasets/datasets.py (list_datasets, list_data, delete_data, empty_dataset, delete_all)
  • cognee/api/v1/datasets/routers/get_datasets_router.py (list, count, raw)
  • cognee/infrastructure/databases/provenance/source_refs.py (per-document ownership of graph elements)
  • cognee/infrastructure/files/utils/open_data_file.py

Extending it

  • Anything new that writes graph nodes or edges for a document must record its source-refs, or forget(data_id=...) cannot find and remove it.
  • Anything new that stores per-document data outside the graph (like edge evidence) needs a cleanup step in the delete path and in memory_only.
  • Unit tests for forget() are in cognee/tests/unit/api/v1/forget/ (argument validation, the HTTP endpoint, memory_only); cover both the document and the memory_only paths for new deletion behaviour.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Operate cognee from the terminal to store, retrieve, update, and remove information. Covers dataset and configuration management, ingestion cost estimates, session history access, and commands for inspecting or applying database migrations.

中文简介正在准备中。当前显示英语简介。

  • Storing documents and asking questions from the terminal
  • Estimating token usage and cost before importing data
  • Managing datasets and saved configuration
topoteretes/cognee3.3万2026年10月19日 更新

Connect cognee to additional databases and data sources through community packages. The skill covers installing and registering adapters, importing data through connectors, configuring monitoring, and developing extension packages with examples and tests.

中文简介正在准备中。当前显示英语简介。

  • Connect cognee to Qdrant or another database
  • Import data from Slack or Gmail
  • Configure monitoring with Keywords AI
topoteretes/cognee3.3万2026年10月19日 更新

Define custom entities and relationships in cognee, a memory system for AI applications. This skill guides model design, identity matching, searchable fields, and troubleshooting when entities are duplicated or relationships are missing.

中文简介正在准备中。当前显示英语简介。

  • Designing custom entities and relationships
  • Preventing duplicate entities across imports
  • Investigating missing search results or relationships
topoteretes/cognee3.3万2026年10月19日 更新

Build custom cognee processing by chaining Python tasks, defining data types, and saving results to graph and vector databases. Use it to enrich existing data, inspect run status, and troubleshoot how tasks pass data.

中文简介正在准备中。当前显示英语简介。

  • Building custom extraction and processing steps
  • Saving custom data types to graph and vector databases
  • Adding information to an existing graph
topoteretes/cognee3.3万2026年10月19日 更新

Run cognee in Docker, starting with a prebuilt image for local document ingestion and questions. It also covers Docker Compose profiles for adding the UI, MCP server, Postgres, and Neo4j, plus persistent data storage.

中文简介正在准备中。当前显示英语简介。

  • Try cognee locally using a prebuilt Docker image
  • Test document ingestion and questions through the API
  • Start the UI, MCP server, and databases with Docker Compose
topoteretes/cognee3.3万2026年10月19日 更新

Store conversations, agent activity, and feedback in cognee sessions, then carry them into long-term memory. This skill explains improve(), its processing stages, result statuses, and settings for diagnosing skipped work or controlling automatic runs.

中文简介正在准备中。当前显示英语简介。

  • Saving conversations and agent activity by session
  • Moving session content into long-term memory
  • Investigating skipped or blocked processing stages
topoteretes/cognee3.3万2026年10月19日 更新

查看 topoteretes 的全部技能

报告此技能的问题