#1916·graphiti

Fuzzy dedup tie-breaking is non-deterministic (PYTHONHASHSEED-dependent entity merges)

Author: linhongyu510Created Sep 24, 2026Updated Sep 30, 2026

Bug

_resolve_with_similarity in graphiti_core/utils/maintenance/dedup_helpers.py picks the best fuzzy entity match by iterating candidate_ids (a set[str]) and keeping the highest Jaccard score with a strict >:

python
candidate_ids: set[str] = set()
...
for candidate_id in candidate_ids:
    score = _jaccard_similarity(shingles, candidate_shingles)
    if score > best_score:
        best_score = score
        best_candidate = indexes.nodes_by_uuid.get(candidate_id)

When two candidates tie on the top score, the retained one is whichever the set happens to yield first. A set[str] iteration order depends on PYTHONHASHSEED, so the same input can merge an extracted entity into a different existing node from one process run to the next.

For a knowledge-graph memory layer this is a silent correctness issue: which canonical node an entity collapses into decides which UUID survives, which edges attach to it, and which uuid_map rewrites propagate downstream — and it becomes non-reproducible across workers.

Reproduction

Two candidates that share the fuzzy-normalized name "alpha bravo" (each scores 1.0 against the extracted node) but keep distinct exact-normalized names ("alpha-bravo" / "alpha/bravo", so they go through the fuzzy path rather than the exact-match branch). With uuids fixed and only PYTHONHASHSEED varied, the extracted node resolves to different existing nodes:

# fixed uuids, 10 seeds:  B A A B B B A A B A   (non-deterministic)

Expected

Tie resolution should be deterministic and reproducible across processes — e.g. break ties on a stable key such as the candidate uuid.

Environment

  • graphiti-core, main
  • Found by auditing the dedup path; analysis and reproduction done with AI assistance and verified manually.

A fix with a regression test is in #1914.