Skip to main content

What is the forget operation

The .forget operation is the unified deletion command in Cognee v1.0. It removes the graph, vector and relational data of what you delete, and drops cached session answers that were built on it; memory_only=True clears only the graph and vector memory so the data can be re-cognified.
  • Single data item deletion: remove one data item from a dataset.
  • Dataset deletion: remove an entire dataset and its graph/vector data.
  • Full cleanup: remove everything the current user can delete.
  • Memory-only reset: delete only graph/vector memory for a dataset or a single file, preserving raw files so the dataset can be re-cognified with different settings.
  • Search history cleanup: clean_history=True also deletes your own search and recall history. Passed alone, it deletes only that history.
  • User-scoped deletion: forget() covers the main v1.0 deletion cases, but it does not replace low-level destructive prune operations.

Where forget fits

  • Use forget() when you want to remove memory.
  • Use it to clean up test data, reset a dataset, or fully wipe a local user’s memory.
  • Use dataset-level forgetting for most operational cleanup.
  • Use prune only for destructive developer resets that must wipe underlying storage or system metadata directly.

What happens under the hood

Forget a specific data item

  • Requires both data_id and dataset.
  • Resolves the dataset by name or UUID with delete-permission checks.
  • Deletes that item from the dataset with delete_dataset_if_empty=False.
  • Removes the session-cache turns whose answers were built on the graph elements this delete removed, so cached answers stop quoting the deleted document.
  • Leaves search history in place: rows are recorded per dataset, not per document, so answers that quoted the document stay until a dataset or everything forget. Pass clean_history=True to also delete your own rows.
  • Leaves the dataset itself intact.

Forget a dataset

  • Resolves the dataset by name or UUID with delete-permission checks.
  • Deletes the dataset’s relational records and contained data items.
  • Deletes graph nodes and edges for that dataset.
  • Deletes vector embeddings for that dataset.
  • Deletes every session in the cache attributed to that dataset, since all of their content derives from data that is now gone, and removes the contaminated turns from sessions that carry no dataset attribution.
  • Deletes every user’s search history recorded for that dataset, before anything else is deleted.

Forget everything

  • Deletes all datasets the current user can delete.
  • Removes graph, vector, and relational data for those datasets.
  • Deletes every row of search history the current user owns, then every user’s rows on each deleted dataset.
  • Deletes every session the current user owns, plus every session attributed to one of the deleted datasets, whoever ran it. Other users’ sessions on datasets you cannot delete stay; the shared session cache is not pruned.
  • Does not wipe raw uploaded files or bypass permission checks the way prune does.

Forget memory only (dataset)

  • Requires dataset. memory_only=True cannot be used without a dataset.
  • Resolves the dataset by name or UUID with delete-permission checks.
  • Deletes all graph nodes and edges for the dataset.
  • Deletes all vector embeddings for the dataset.
  • Deletes every session attributed to the dataset — their cached answers assert graph content that no longer exists, and a re-cognify with different settings should not replay them — and removes the contaminated turns from sessions that carry no dataset attribution.
  • Resets pipeline_status on all data records in the dataset, allowing cognify to re-process them.
  • Does not remove raw files or the dataset/data relational records.

Forget memory only (single file)

  • Requires both dataset and data_id, plus memory_only=True.
  • Resolves the dataset by name or UUID with delete-permission checks.
  • Deletes the graph nodes and edges associated with that single data item.
  • Deletes the vector embeddings for that data item.
  • Removes only the contaminated session-cache entries: turns whose answers used the deleted graph elements, plus anything that inherited from them (see the scope matrix below). Untouched turns in the same session survive.
  • Resets the cognify_pipeline status entry for that data record, allowing re-processing.
  • Does not remove the raw file or the data record itself.

After forget finishes

  • Single-item forget: the specified item is removed from the dataset, while the dataset remains. Session turns that used the item’s graph elements are removed; the rest of each session survives.
  • Dataset forget: the dataset’s relational, graph, and vector data are removed, along with the sessions attributed to it and the contaminated turns in unattributed sessions.
  • Everything forget: all datasets the current user can delete are removed, together with the sessions the user owns and the sessions attributed to those datasets. Other users’ sessions on datasets the user cannot delete stay.
  • Memory-only (dataset): graph, vector, and pipeline status are cleared, the dataset’s sessions are deleted, and the contaminated turns in unattributed sessions are removed; the dataset, data records, and raw files remain intact and can be re-cognified.
  • Memory-only (single file): graph nodes/edges and vector embeddings for that file are removed, together with the session turns built on them; the data record and raw file are preserved.
A search that finds nothing after memory_only=True does not mean the data is gone: the document is still stored, and the next cognify processes it again. Every mode also removes records and memory, not the stored bytes — see What stays on disk.

Examples and details

Forget a single data item

Use this when you want to re-cognify a dataset with different settings (e.g. a new graph model or custom prompt) without removing the original files.
Graph nodes/edges and vector embeddings are deleted and the pipeline status is reset. Raw files and the dataset/data records are preserved.
Clears just the graph and vector memory for one file, without touching the rest of the dataset.
clean_history=True deletes the caller’s own search and recall history: every queries/results row the user owns, in any dataset. These are the rows GET /api/v1/search and GET /api/v1/recall list, and the same rows DELETE /api/v1/search/history removes. Other users’ history is not touched.
How each mode treats history:
  • Dataset and everything=True forgets purge the deleted datasets’ history for every user, with or without the flag. everything=True also deletes all of the caller’s own rows, so it always reports history_cleaned: True.
  • Single-item forgets do not purge dataset history, because history is recorded per dataset, not per document. Answers that quoted the document stay until a dataset or everything=True forget, unless you pass clean_history=True to remove your own rows.
  • Memory-only forgets leave history unless clean_history=True is set.
Over HTTP, send cleanHistory (or clean_history) in the POST /api/v1/forget body. In the CLI, use cognee-cli forget --clean-history.
forget() returns a summary dictionary.
  • Item deletion returns the delete_data() receipt: status, dataset_id, data_id (the resolved id, which differs from the input when a legacy id was passed), data_record_found, deleted_nodes, deleted_edges, data_remaining, and dataset_deleted, plus search_history_removed: False. status is "not_found" when nothing existed for the id; that is not an error, and nothing was removed.
  • Dataset deletion returns the resolved dataset_id, search_history_removed: True, and status.
  • Full deletion returns the number of datasets removed (datasets_removed), the number of sessions removed (sessions_removed), search_history_removed: True, and status.
  • Memory-only dataset reset returns dataset_id, data_records_reset (count of data records in the dataset), and status.
  • Memory-only single-file reset returns data_id, dataset_id, and status.
  • clean_history=True with no target returns only history_cleaned: True and status.
Every result also carries history_cleaned, which reports whether the caller’s own search history was deleted. For dataset and data-item modes it equals the clean_history argument; everything=True always returns True.Over HTTP, POST /api/v1/forget returns these results with snake_case keys, because the route answers several result shapes. The data-delete routes (DELETE /api/v1/datasets/{dataset_id}/data/{data_id} and the deprecated DELETE /api/v1/delete) return the same item receipt with camelCase keys.
Every mode cleans up session memory, so cached answers stop quoting content the delete removed. The two granularities differ:
  • Dataset-level deletes (dataset, dataset + memory_only=True, and each dataset visited by everything=True) drop whole sessions — every session attributed to the dataset, found through the dataset_id recorded on the session or the per-dataset default session id (default_session_<dataset_id>) — and then apply the surgical pass below to sessions with no dataset attribution, so an answer that drew on the deleted content from the global default_session is removed too.
  • Single-item deletes (data_id + dataset, with or without memory_only=True) are surgical. A turn is contaminated when the graph elements it recorded using overlap the nodes and edges this delete removed. Contamination then propagates inside that session — a contaminated turn taints feedback that references it, feedback taints the distilled session-context lesson it fed, and that lesson taints later turns that consumed it — and the whole chain is removed. Everything else in the session is kept.
Search history (the saved questions and answers, see Search History Retention) is purged for every user only by the dataset and everything=True modes; clean_history=True deletes only the caller’s own rows. search_history_removed: True means every row recorded for the deleted datasets is gone, not that no row mentions them. Rows saved without a dataset (written before cognee 1.5.0, or by a search over several datasets with backend access control off) are matched only by owner: a dataset forget leaves them, and forget(everything=True) removes only the caller’s own. The memory_only modes leave history untouched unless clean_history=True is set.forget(everything=True) also deletes every session you own, whatever dataset it is attributed to. It never prunes the cache wholesale: the cache is shared by every user, so other users’ sessions on datasets you cannot delete and the cache’s shared lock rows stay. None of these modes is a raw-storage/system-metadata reset like prune. The memory_only modes are the only modes that preserve relational records while clearing derived knowledge.
Every forget() mode removes the records and the memory it names; it does not scrub the bytes from the storage engines.
  • LanceDB (the default vector store) keeps deleted rows in its append-only fragments until compaction rewrites them, and it rewrites a fragment only once enough of it is deleted. A small delete in a large table can therefore stay on disk indefinitely. See LanceDB storage compaction.
  • The embedded graph file (Ladybug, the default graph store) has no user-facing compaction.
If you need a byte-level erasure guarantee, run the storage engine’s own compaction or vacuum, or move to a new store.
No. forget() (and the legacy delete()) only remove data — they never call the LLM or embedding model, so they consume no tokens and incur no model cost.Under the hood, forgetting performs deletes against the relational, graph, and vector stores. It does not re-extract entities, re-embed text, or rebuild graph relationships. Existing nodes and edges are simply dropped (or preserved when still shared, as described below); the remaining graph is left as-is and is not recomputed.When you rebuild memory after a forget, model calls happen in the operations that build memory — remember/cognify and memify. Tokens are spent only when you re-cognify after a memory_only forget, not by the forget itself.
A common misconception is that item-level deletion only considers graph nodes. In practice Cognee also records relationship ownership metadata per source document: when cognify builds the graph, it records which graph nodes and which edges (relationships) were derived from each source.When you forget a single data item (with or without memory_only), Cognee uses those ownership records to identify graph memory tied to that item:The per-document ownership records are always cleared, even when every node the document referenced is shared and therefore kept in the graph. Graph relationships attached to deleted nodes are removed with those nodes; relationships between surviving shared nodes are not independently deleted by forget().To replace a document’s extracted graph memory with memory from new content, use update(), whose full rebuild runs this item-level deletion with memory_only=True — keeping the document’s record and stored files — and then re-cognifies the new version.
forget() always runs in a user context.
  • If you do not pass user, Cognee resolves the default user.
  • Deletion scope is based on what that user owns or has delete access to.
  • everything=True means “everything the current user can delete,” not “everything in the whole system.”
  • This is why the user parameter matters in multi-user or permissioned setups.
  • Deleting a specific item or dataset requires delete access to that dataset.
  • Dataset resolution filters by the delete permission, so a dataset you can only read is indistinguishable from one that does not exist. A name that resolves to nothing fails with DatasetNotFoundError: Dataset '<name>' not found or not accessible. (HTTP 404); a UUID you cannot delete fails with PermissionDeniedError: Request owner does not have necessary permission: [delete] for all datasets requested. (HTTP 403). See troubleshooting dataset resolution.
  • data_id cannot be used alone; it must be paired with dataset.
  • memory_only=True requires dataset to be specified; omitting it raises a ValueError.
  • memory_only operations check delete permission on the dataset before removing any graph or vector data.
  • everything=True ignores data_id and dataset and wipes all data the current user can delete.
  • The search-history purge is not best-effort: it runs before each dataset is deleted, and if it fails, forget() raises with that dataset still in place, so the same call can be retried.
  • Session-cache cleanup is best-effort by contract: it never fails the delete that triggered it. If the cache is unavailable or a session cannot be cleaned, Cognee logs a warning and the relational, graph, and vector deletions still complete. A "status": "success" result therefore does not guarantee that every session entry was removed — check the logs if stale cached answers persist.
  • The exception is the session deletion of everything=True: it runs before any dataset is deleted, and if it fails, forget() raises with every dataset still in place (your own search history is already gone by then), so the same call can be retried.
  • clean_history=True is not best-effort. The target is validated first, so an invalid combination raises without touching the history. The caller’s history is then deleted before any data, and a failure raises, so nothing has been deleted yet and the forget can be retried. The dataset is resolved only after the history is gone, so a dataset that does not exist or that you cannot delete still loses your history before the call fails.
  • forget() is not a substitute for prune_data() or prune_system(...), which are lower-level destructive maintenance tools.
forget() wraps the Delete and dataset-deletion APIs under the hood, extending them with a unified interface and session cache cleanup.Use legacy Delete directly only when maintaining older integrations or referencing older documentation. For destructive storage resets that bypass normal deletion logic, use prune rather than forget().
To find the dataset name or data_id needed for forget(), list your datasets and their contents first:
See datasets API reference for the full set of listing and management methods.

Remember

Add new permanent or session memory

Recall

Verify what memory is currently retrievable