> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Forget

> Delete data, datasets, or memory-only state with forget.

## What is the forget operation

The `.forget` operation is the unified deletion command in Cognee v1.0.

* **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.
* **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 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.

### Forget everything

* Deletes all datasets the current user can delete.
* Removes graph, vector, and relational data for those datasets.
* Also prunes the session cache when caching or usage logging is enabled.
* 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.
* 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.
* **Everything forget**: all datasets the current user can delete are removed, and the session cache is pruned wholesale when session caching or usage logging is enabled.
* **Memory-only (dataset)**: graph, vector, and pipeline status are cleared and the dataset's sessions are deleted; 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.

## Examples and details

<Accordion title="Forget a single data item" defaultOpen>
  ```python theme={null}
  await cognee.forget(
      data_id=item_id,
      dataset=dataset_id,
  )
  ```
</Accordion>

<Accordion title="Forget an entire dataset">
  ```python theme={null}
  await cognee.forget(dataset="scientists")
  ```
</Accordion>

<Accordion title="Forget everything for the current user">
  ```python theme={null}
  await cognee.forget(everything=True)
  ```
</Accordion>

<Accordion title="Forget only memory for a dataset (keep raw files)">
  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.

  ```python theme={null}
  await cognee.forget(dataset="scientists", memory_only=True)
  ```

  Graph nodes/edges and vector embeddings are deleted and the pipeline status is reset.
  Raw files and the dataset/data records are preserved.
</Accordion>

<Accordion title="Forget only memory for a single file">
  Clears just the graph and vector memory for one file, without touching the rest of the dataset.

  ```python theme={null}
  await cognee.forget(
      dataset="scientists",
      data_id=item_id,
      memory_only=True,
  )
  ```
</Accordion>

<Accordion title="Return values">
  `forget()` returns a summary dictionary.

  * Item deletion returns fields like `data_id`, `dataset_id`, and `status`.
  * Dataset deletion returns the resolved `dataset_id` and `status`.
  * Full deletion returns the number of datasets removed plus `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`.
</Accordion>

<Accordion title="Deletion scope by mode">
  | Mode                                       | Relational data                | Graph data                     | Vector data                    | Pipeline status         | Raw files | Session cache                                           |
  | ------------------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | ----------------------- | --------- | ------------------------------------------------------- |
  | `data_id` + `dataset`                      | removes the targeted item      | removed for that item          | removed for that item          | unchanged               | preserved | contaminated turns removed                              |
  | `dataset`                                  | removed                        | removed                        | removed                        | removed                 | preserved | sessions for that dataset deleted                       |
  | `everything=True`                          | removed for all owned datasets | removed for all owned datasets | removed for all owned datasets | removed                 | preserved | pruned when session caching or usage logging is enabled |
  | `dataset` + `memory_only=True`             | preserved                      | removed                        | removed                        | reset (cognify re-runs) | preserved | sessions for that dataset deleted                       |
  | `dataset` + `data_id` + `memory_only=True` | preserved                      | removed for that item          | removed for that item          | reset for that item     | preserved | contaminated turns removed                              |

  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>`).
  * **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.

  `forget(everything=True)` remains the only mode that also prunes the cache wholesale (including sessions with no dataset attribution), and 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.
</Accordion>

<Accordion title="Does forget re-run the LLM or cost tokens?">
  No. `forget()` (and the legacy [`delete()`](/core-concepts/main-operations/legacy-operations/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`](/core-concepts/main-operations/remember)/`cognify` and [`memify`](/core-concepts/main-operations/legacy-operations/memify). Tokens are spent only when you re-cognify after a `memory_only` forget, not by the forget itself.
</Accordion>

<Accordion title="What is tracked per document: nodes and relationships">
  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:

  | Owned by the removed document        | Also referenced by another document in scope | Result                                              |
  | ------------------------------------ | -------------------------------------------- | --------------------------------------------------- |
  | node                                 | no                                           | **deleted** from graph + vector stores (orphaned)   |
  | node                                 | yes                                          | **preserved** so the rest of the graph stays intact |
  | relationship metadata / edge indexes | no longer referenced                         | **cleaned up** along with the removed graph memory  |
  | relationship metadata                | still referenced                             | **preserved** for the remaining graph memory        |

  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()`](/python-api/update), which runs this same item-level deletion flow and then re-cognifies the new version.
</Accordion>

<Accordion title="User context and ownership">
  `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.
</Accordion>

<Accordion title="Parameters">
  <Tabs>
    <Tab title="Basic Parameters">
      | Option        | What it does                                                                                                                                                                                    |
      | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `dataset`     | Deletes an entire dataset by name or UUID.                                                                                                                                                      |
      | `data_id`     | Deletes one specific data item, but only when `dataset` is also provided.                                                                                                                       |
      | `everything`  | Deletes all datasets and data the current user can delete.                                                                                                                                      |
      | `memory_only` | When `True`, deletes only memory (graph + vector) and resets pipeline status for the given `dataset`, preserving raw files. Requires `dataset`. Combine with `data_id` to target a single file. |
    </Tab>

    <Tab title="Advanced Parameters">
      | Option | What it does                                                                              |
      | ------ | ----------------------------------------------------------------------------------------- |
      | `user` | Runs forget under a specific user context, affecting ownership checks and deletion scope. |
    </Tab>
  </Tabs>
</Accordion>

<Accordion title="Permissions and safety">
  * Deleting a specific item or dataset requires delete access to that dataset.
  * `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.
  * 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.
  * `forget()` is not a substitute for `prune_data()` or `prune_system(...)`, which are lower-level destructive maintenance tools.
</Accordion>

<Accordion title="Under the hood — legacy operations">
  `forget()` wraps the [Delete](/core-concepts/main-operations/legacy-operations/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()`.
</Accordion>

<Accordion title="Inspect what you've stored before forgetting">
  To find the dataset name or `data_id` needed for `forget()`, list your datasets and their contents first:

  ```python theme={null}
  import cognee

  # See all datasets
  datasets = await cognee.datasets.list_datasets()
  for ds in datasets:
      print(ds.name, ds.id)

  # See items inside a specific dataset
  items = await cognee.datasets.list_data(dataset_id=ds.id)
  for item in items:
      print(item.id, item.name)
  ```

  See [datasets API reference](/python-api/datasets) for the full set of listing and management methods.
</Accordion>

<Columns cols={2}>
  <Card title="Remember" icon="brain" href="/core-concepts/main-operations/remember">
    Add new permanent or session memory
  </Card>

  <Card title="Recall" icon="search" href="/core-concepts/main-operations/recall">
    Verify what memory is currently retrievable
  </Card>
</Columns>
