Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured β the analyze phase is deterministic, but the apply phase runs cognify
- Read Datasets β presort ingests each proposed group into its own dataset
- Set
PRESORT_FOLDERto the folder you want to scan, or let the script use~/Downloads - Name that folder as a permitted scan root before running the script β the defaults are the working directory, the temp directory, and cogneeβs own storage, so a folder under
$HOMEis always outside them:export COGNEE_ALLOWED_LOCAL_FILE_ROOTS="$HOME/Downloads". See Presort scan roots
Code in Action
examples/guides/presort_downloads.py.
What Just Happened
Step 1: Scan the Folder
dry_run="presort" turns remember() into an analyzer: it walks the folder, reads samples of the files, and returns a PresortReport instead of ingesting anything. Nothing on disk is moved, renamed, or deleted. The report is also saved to <SYSTEM_ROOT_DIRECTORY>/presort/<scan_id>.presort.json, so the analyze result survives a failed apply β report.report_path holds the exact location, or None when SYSTEM_ROOT_DIRECTORY is unset or on S3 and the report was not persisted.
Step 2: Review the Report
report.summary() is the at-a-glance view: file and junk counts, exact-duplicate clusters with the bytes they waste, version candidates, potential personal data, and a cognee_status breakdown of how many files are new, staged, or already cognified. report.groups holds the proposal itself β each group carries the dataset_name it would land in and the files it would take there.
Step 3: Set the Apply Decisions
exclude_pii defaults to False, so setting it is what actually changes the run β it drops files with potential personal data. skip_duplicates is already on by default; it is spelled out to keep the decision visible. apply_groups narrows the run to the groups you name β here every group except code projects, which belong in a code graph rather than a document dataset.
Step 4: Apply the Report and Recall
remember() runs the second phase: each approved group goes through the normal add β cognify chain into its own dataset, and you get back a {dataset_name: result} mapping. Ingestion is incremental, so re-running the script after adding a few files only processes what is new. From there the folder is ordinary cognee memory β recall() takes the dataset names as its scope.
Advanced Usage
Deterministic scan vs. LLM analysis
Deterministic scan vs. LLM analysis
The analyze phase needs no LLM or embedding configuration: junk filtering, duplicate detection, version candidates, and folder-based grouping are all deterministic. Pass
use_llm=True to remember(folder, dry_run="presort", use_llm=True) for LLM content classification, deeper PII detection, and semantic grouping.The apply phase runs cognify and does need a configured LLM. Without one, presort degrades rather than fails: the deterministic scan still runs, use_llm is downgraded, and apply stages files with add() only β each reported as a warning on the report.Skipping the review step
Skipping the review step
When you trust the defaults,
remember(FOLDER, dry_run="presort", auto_apply=True) collapses both phases into one call instead of the two this guide makes β see auto_apply for what comes back.Running presort from the CLI
Running presort from the CLI
cognee-cli remember <folder> --presort runs the same two phases from the shell, with --allow-root in place of the environment variable. The commands and their apply-time flags are in the CLI reference.Datasets
How the datasets presort proposes organize documents, permissions, and processing.
remember()
Every option the two presort phases accept, including the apply overrides.