Skip to main content

cognee.remember()

Description

remember() is the main ingestion entry point in Cognee v1.0.
  • Without session_id, it stores permanent memory by running the ingestion pipeline for you.
  • With session_id, it stores session memory in the cache for fast short-term retrieval.
  • When self_improvement=True, Cognee also runs improve() to enrich the graph or bridge session content into permanent memory.
Because permanent memory is built through cognify(), the cognify feature flags apply to remember() too. Notably, setting CONTRADICTION_DETECTION=true makes every remember() call check the facts it just stored against the ones already in the graph and record each conflict as a contradicts edge — see Contradiction detection — and PROVENANCE_TRACKING=true makes it append an audit-ledger entry for every document, chunk, entity, and relationship it produced, see Provenance ledger. Both off by default. For the full behavior walkthrough, see Remember.

Parameters

Union[BinaryIO, list[BinaryIO], str, list[str], DataItem, list[DataItem], MemoryEntry, PresortReport, dict]
required
Content to store. Supports text, file paths, URLs, file-like objects, DataItem values, lists of supported inputs, and typed session-memory entries. A GitHub/GitLab repository URL is recognised by shape, shallow-cloned, and indexed as a code graph rather than fetched as a web page — see add() and the Code Graph guide. A PresortReport (or a path ending in .presort.json) is recognised as a presort report and applied instead of ingested — see Folder presort.
str
default:"'main_dataset'"
Target dataset for permanent memory or for session-to-graph bridging.
Optional[str]
default:"None"
Enables session-memory mode. When set, content is written to the session cache instead of going straight into the permanent graph.
Optional[int]
default:"None"
Maximum chunk size for permanent ingestion. When omitted, Cognee uses its default chunking behavior.
Optional[Any]
default:"None"
Custom chunking strategy for permanent ingestion.
Optional[str]
default:"None"
Overrides the prompt used during graph extraction.
bool
default:"False"
Starts the work asynchronously and returns a RememberResult you can await later.
bool
default:"True"
When enabled, runs improve() automatically after storage to enrich the graph or bridge session content.
Optional[List[str]]
default:"None"
Session IDs to sync newly enriched graph knowledge back into during the improvement pass.
Union[bool, Literal['presort']]
default:"False"
When True, return a DryRunEstimate of LLM token usage and rough cost instead of ingesting data. No LLM calls are made, no data is ingested, and no graph is written. See Dry-run cost estimation.When "presort", treat data as a folder path and return a PresortReport instead of ingesting. This is a separate feature that happens to share the parameter — see Folder presort.
bool
default:"True"
Forwarded to the internal cognify() step. When true, a blocking remember() whose graph build errored raises CognifyFailedError instead of returning a RememberResult with status="errored". Set False to keep the previous behavior. See Failed runs.

Dry-run cost estimation

Pass dry_run=True to preview the LLM token usage and rough USD cost of a permanent remember() run without ingesting data, making LLM calls, or writing the graph:
The call returns a DryRunEstimate with a stage-level breakdown (structured_graph_extraction and chunk_summarization). Its operation field is "remember"; the full field reference is documented under cognify() → Dry-run cost estimation. Supported inputs: raw text, local text files, and file:// URIs. Dataset resolution for the estimate is read-only. The estimator mirrors real ingestion routing, so a bare path string is only read from disk when that file exists. An absolute-looking string that does not exist (for example "/remember to call the dentist") is priced as raw text instead of failing, matching what a real run would ingest and bill. Local path inputs are also subject to ACCEPT_LOCAL_FILE_PATH, and the estimator detects absolute paths the same way real ingestion does — including Windows drive-letter paths such as C:\notes.txt. When the flag is disabled, a file:// URI or a string pointing at an existing absolute local file raises rather than being estimated; an existing relative path, and any string that is not an existing file, are still priced as raw text. Rejected inputs (raise a ValueError rather than being silently mis-estimated):
  • session_id (session memory) — dry run only supports the permanent add+cognify path
  • Typed MemoryEntry values and MemorySource imports
  • Any content_type override, including content_type="skills" and content_type="code"
  • Remote (serve()) mode — call cognee.disconnect() to estimate locally
  • Remote URLs (http/https/s3), directories, and binary formats (PDF, images, audio, Office documents) that a real run would fetch, walk, or transcribe
The estimate excludes the extra LLM calls that improve() makes when self_improvement=True (the default), as well as embedding costs.

Folder presort

Presort is a two-phase pre-ingestion pass for messy folders. It shares the dry_run parameter with the cost estimator above, but is an unrelated feature: nothing is priced, and the folder is inspected rather than ingested. For a runnable walkthrough of both phases, see the Folder Presort guide.
Pass auto_apply=True to do both in one call. The report is still produced and persisted first, and the ingest outcomes ride back on report.apply_results ({dataset_name: RememberResult}):
The analyze phase is deterministic by default — no LLM or embedding configuration is required. Pass use_llm=True to add LLM content classification, deeper PII detection, and semantic grouping.

The report

remember(folder, dry_run="presort") returns a PresortReport (cognee.tasks.presort.models). It is a Pydantic model, so to_dict(), to_json(), save(path), and PresortReport.from_json(source) are all available, and summary() returns the counts the CLI prints. Unless SYSTEM_ROOT_DIRECTORY is unset or on S3, the report is also saved automatically to <SYSTEM_ROOT_DIRECTORY>/presort/<scan_id>.presort.json, so the analyze result survives even when apply fails.

Applying a report

remember() recognises a report passed as data in three shapes: a PresortReport object, a dict carrying the presort_report: true marker, or a path ending in .presort.json. Ordinary .json ingestion is unaffected — only that exact suffix is treated as a report. Apply ingests each selected group into its proposed dataset through the normal add → cognify (→ improve) chain with incremental_loading=True, so re-applying is idempotent: content the report marked cognified is skipped by the pipeline. Each group’s items are tagged with the node set ["presort", "<group name>"]. It returns {dataset_name: RememberResult}, not a single RememberResult; with apply_graph=True the relationship graph’s outcome rides along under the extra key presort_graph.

Presort options

Analyze-phase keywords (dry_run="presort"): Apply-phase keywords (remember(report), or alongside auto_apply=True). When omitted, the value stored on the report is used:

Without a configured LLM

Presort degrades instead of failing. The deterministic scan always runs; use_llm is downgraded to the deterministic pass; apply stages files with add() only, leaving cognify/improve for later; and apply_graph is skipped because writing the relationship graph needs embeddings. Each degradation is recorded as a warning on the report and logged.

Automatic presort

Set PRESORT_FOLDERS_ENABLED=true to presort plain folders automatically, with auto_apply on by default. The environment flag defaults to false, so ordinary remember(folder) calls are unchanged unless you opt in. Even when enabled, automatic presort applies only to a local directory path targeting main_dataset with no session_id, no dataset_id, and no content_type. Code-project directories keep the code-graph route, and remote (serve()) mode is excluded.

Restrictions

Presort scans the local filesystem, and is bounded to the permitted presort roots. Scanning a folder outside them raises ValueError: Path is outside the allowed local file roots. Add the folder to COGNEE_ALLOWED_LOCAL_FILE_ROOTS (os.pathsep-separated list) to allow it, or use the CLI's --allow-root flag.; reading a saved report from outside them raises the shorter ValueError: Local file path is outside allowed roots. ValueError is also raised for:
  • dry_run="presort" with session_id or any content_type
  • dry_run="presort" while connected to a remote instance via serve() — call cognee.disconnect() first
  • more than one folder path in a single presort call, or a file path instead of a folder
  • dry_run or session_id combined with applying a report

Additional keyword options

These power-user options are forwarded to the underlying ingestion and graph-building steps.

Return value

remember() returns:
  • RememberResult for normal ingestion runs. You can inspect fields like status, dataset_name, session_ids, elapsed_seconds, and raw_result, or await the result when background mode is enabled.
  • DryRunEstimate when dry_run=True, with aggregate token/cost totals plus the per-stage breakdown described above.
  • PresortReport when dry_run="presort", described under Folder presort.
  • dict of {dataset_name: RememberResult} when data is a presort report.
A blocking permanent-memory run whose graph build fails does not return a RememberResult with status="errored" — it raises CognifyFailedError, carrying the dataset name and the root cause (error_class, error_message). Pass raise_on_error=False to get the errored result object back instead:
Background runs (run_in_background=True) still surface the failure on the result object rather than raising, since there is no caller left to catch the exception: await the result and read status == "errored" along with pipeline_run_id and raw_result. See Failed runs for the full behavior of the underlying cognify() step.

Examples

See also add() and cognify() if you need direct control over the legacy pipeline steps.