Skip to main content
A minimal guide to reviewing conflicting facts with improve(). Use it when two sources in the same dataset assert different values for one attribute — here, two documents naming different CEOs for the same company — and you want Cognee to record the disagreement, ordered by each source’s date, instead of silently keeping both. The review stage runs by default on every improve(), including the automatic one after remember(); IMPROVE_REVIEW_CONFLICTS=false or improve(review_conflicts=False) turns it off, and the code below passes review_conflicts=True only to pin it on.

Before You Start

  • Complete Quickstart to understand basic operations
  • Ensure you have LLM Providers configured — the review stage is skipped when no LLM is available
  • Read Improve for how improve() runs its stages, including review_conflicts
  • Keep EDGE_EVIDENCE_ENABLED at its default true — the review stage is skipped when edge evidence is off
  • Use a graph adapter that implements delete_edge_triples — Ladybug, Neo4j, Neptune, Postgres, and Turso all do; on an adapter that doesn’t, rewriting a stored conflict raises UnsupportedProvenanceCapability

Code in Action

The dataset is kept after the run so you can inspect it, and every run uses a fresh dataset name.

What Just Happened

Step 1: Remember Dated Facts

Each source is wrapped in a DataItem whose external_metadata carries the date the source’s claims hold as of, under the key the review reads (effective_date by default, configurable with IMPROVE_EFFECTIVE_DATE_KEY). self_improvement=False keeps remember() from improving on its own, so the review runs only when the script asks for it.

Step 2: Run the Conflict Review

review_conflicts=True runs the review_conflicts stage of improve(). The stage is on by default (IMPROVE_REVIEW_CONFLICTS defaults to true), so the argument only makes it explicit here; review_conflicts=False or IMPROVE_REVIEW_CONFLICTS=false turns it off. In cognee 1.6.5 and earlier the stage is off by default, and the argument is what turns it on. Only the facts that could disagree go to the LLM: values of one kind for one entity that come from at least two documents, statements from different documents that give different numbers, dates, or codes for one thing, and the facts of conflicts already stored. Each call covers at most 25 entities and 8,000 input tokens, or half the model’s token limit when that is lower. The LLM reviews those facts and their dates, and the stage stores each disagreement it accepts as a FactConflict node with marks on the facts it covers. Entity descriptions stay as extracted. result.stage("review_conflicts") returns that stage’s result, including its status.

Step 3: Inspect the Stored Conflicts

Each FactConflict node describes one attribute of one entity with competing values, and its outgoing edges link it to the entity it is about, the competing values, and the source chunks it cites. The facts themselves carry conflict marks — read_conflict_marks() reads them on any graph backend — that record each fact’s status within the conflict: current, superseded, or conflicting.

Step 4: Repeat on Unchanged Data

The review keeps a watermark per dataset and re-reviews only entities whose facts changed since the last run. With no new facts and no unfinished conflicts to repair, the second run reports the stage as already_completed instead of calling the LLM again. Later runs send only the value groups and statement pairs that gained a fact since the last review. The stage’s counts report entities_failed, the entities whose review failed: the next run reviews them again with all their facts. They also report entities_skipped, the entities whose facts do not fit one call. Those are not retried.

Resolve Conflicting Facts

Settle a conflict the review cannot decide with list_conflicts() and resolve_conflict().

Self-Improving Memory Quickstart

How improve() runs its stages and what each one does.

Temporal Knowledge Graph

The other time axis: when a fact happened, not when its source dated it.