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

# Resolve Conflicting Facts

> Use list_conflicts() and resolve_conflict() to settle a conflict that conflict review cannot decide, and see recall use the choice

A minimal guide to settling a stored conflict yourself. Use it when two sources disagree on a fact that never changes over time, such as where a company was founded, so conflict review cannot pick a winner, and you want to record which fact you accept.

## Before You Start

* Complete [Quickstart](https://docs.cognee.ai/getting-started/quickstart.md) to understand basic operations
* Ensure you have [LLM Providers](https://docs.cognee.ai/setup-configuration/llm-providers.md) configured
* Read [Review Conflicting Facts](https://docs.cognee.ai/guides/review-conflicts.md) for how `improve(review_conflicts=True)` finds and stores conflicts
* Keep [`EDGE_EVIDENCE_ENABLED`](https://docs.cognee.ai/setup-configuration/overview#edge-evidence) at its default `true`. Conflict review is skipped when it is off

## Code in Action

```python theme={null}
import asyncio
from uuid import UUID

import cognee
from cognee.modules.data.exceptions import DatasetNotFoundError
from cognee.modules.search.types import SearchType
from cognee.tasks.ingestion.data_item import DataItem

DATASET = "resolve_conflicts"
QUESTION = "Where was Acme founded?"


async def main():
    try:
        await cognee.forget(dataset=DATASET)
    except DatasetNotFoundError:
        pass  # First run: the dataset does not exist yet.

    # 1. Two sources that disagree on a fact that cannot change over time.
    for label, text in [
        ("Company registry", "Acme was founded in Berlin."),
        ("Conference speaker bio", "Acme was founded in Munich."),
    ]:
        result = await cognee.remember(
            DataItem(text, label=label, literal_text=True),
            dataset_name=DATASET,
            self_improvement=False,
        )
    dataset_id = UUID(str(result.dataset_id))

    # 2. Conflict review records the disagreement but cannot settle it.
    await cognee.improve(dataset=DATASET, review_conflicts=True)
    conflict = (await cognee.list_conflicts(dataset_id, status="unresolved"))[0]
    print("Unresolved conflict:", conflict.attribute, [fact.text for fact in conflict.facts])
    before = await cognee.recall(
        QUESTION, query_type=SearchType.GRAPH_COMPLETION, datasets=[DATASET]
    )
    print("Before the decision:", before[0].text)

    # 3. The user accepts the registry's fact. The id must be one of the conflict's facts.
    berlin = next(fact for fact in conflict.facts if "Berlin" in fact.text)
    resolved = await cognee.resolve_conflict(
        conflict.id,
        dataset_id=dataset_id,
        selected_fact_id=berlin.id,
        reason="The company registry is the authoritative source.",
    )
    print("Resolved:", resolved.status, "-", resolved.selected_fact)
    after = await cognee.recall(
        QUESTION, query_type=SearchType.GRAPH_COMPLETION, datasets=[DATASET]
    )
    print("After the decision:", after[0].text)

    # 4. A later automatic review keeps the user's decision.
    await cognee.improve(dataset=DATASET, review_conflicts=True)
    kept = (await cognee.list_conflicts(dataset_id))[0]
    print("After another review:", kept.status, "-", kept.selected_fact)


if __name__ == "__main__":
    asyncio.run(main())
```

## What Just Happened

### Step 1: Remember Two Disagreeing Sources

```python theme={null}
for label, text in [
    ("Company registry", "Acme was founded in Berlin."),
    ("Conference speaker bio", "Acme was founded in Munich."),
]:
    result = await cognee.remember(
        DataItem(text, label=label, literal_text=True),
        dataset_name=DATASET,
        self_improvement=False,
    )
dataset_id = UUID(str(result.dataset_id))
```

Each source is stored as its own labelled `DataItem` in one dataset. `self_improvement=False` keeps `remember()` from running `improve()` on its own, so the conflict review runs only when the script asks for it. The dataset id is kept because the conflict functions take an id, not a name.

### Step 2: Review and List the Unresolved Conflict

```python theme={null}
await cognee.improve(dataset=DATASET, review_conflicts=True)
conflict = (await cognee.list_conflicts(dataset_id, status="unresolved"))[0]
print("Unresolved conflict:", conflict.attribute, [fact.text for fact in conflict.facts])
```

A founding city never changes, so the review stores the disagreement as a conflict but cannot choose a winner, and leaves it unresolved. `cognee.list_conflicts()` returns the dataset's conflicts, and `status` can narrow them to `"resolved"` or `"unresolved"`. Each conflict lists its competing facts with their ids and text.

### Step 3: Resolve the Conflict

```python theme={null}
berlin = next(fact for fact in conflict.facts if "Berlin" in fact.text)
resolved = await cognee.resolve_conflict(
    conflict.id,
    dataset_id=dataset_id,
    selected_fact_id=berlin.id,
    reason="The company registry is the authoritative source.",
)
```

`cognee.resolve_conflict()` records which fact you accept. `selected_fact_id` must be the id of one of the conflict's facts, or the call raises a validation error. The other facts are not deleted: they stay in the graph as superseded. Recall applies the decision at query time, with no further `improve()` run: graph completion drops the rejected facts from its context and states the accepted one, so the answer printed after the decision follows your choice.

### Step 4: Confirm the Decision Is Kept

```python theme={null}
await cognee.improve(dataset=DATASET, review_conflicts=True)
kept = (await cognee.list_conflicts(dataset_id))[0]
print("After another review:", kept.status, "-", kept.selected_fact)
```

A later conflict review does not overturn your decision. It keeps it for as long as the selected fact exists. Calling `resolve_conflict()` again with a different fact replaces the earlier decision. See [`list_conflicts()` and `resolve_conflict()`](https://docs.cognee.ai/python-api/conflicts) for the full signatures, permissions, and the HTTP endpoints.

> **[Review Conflicting Facts](https://docs.cognee.ai/guides/review-conflicts.md)**
>
> How conflict review finds disagreeing facts and stores them.

> **[Self-Improving Memory Quickstart](https://docs.cognee.ai/guides/self-improving-memory-quickstart.md)**
>
> How `improve()` runs its stages and what each one does.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.