Conflict Detection
The problem
Section titled “The problem”Facts change. A user moves cities, changes jobs, starts a new relationship. The memory system needs to detect when new information contradicts or updates existing memories, and handle the transition gracefully.
How conflict detection works
Section titled “How conflict detection works”When a new memory is stored, the system checks it against existing high-importance and core memories:
- Filter candidates: Only check against non-superseded memories with importance > 0.5 or core category (for efficiency).
- Similarity gate: Compute cosine similarity between the new memory and each candidate. Only check pairs with similarity >= 0.6 (topically related).
- LLM classification: Ask the LLM to classify the relationship between the two memories.
Conflict types
Section titled “Conflict types”The LLM classifies each pair into one of four categories:
| Type | Meaning | Example |
|---|---|---|
CONTRADICTION | The new memory directly negates the existing one | ”User is vegetarian” vs “User ate steak last night” |
UPDATE | The new memory is a newer version of the same fact | ”User lives in Portland” vs “User moved to Seattle” |
OVERLAP | They cover similar ground but don’t conflict | ”User likes coffee” vs “User drinks coffee every morning” |
NONE | They are unrelated | ”User likes coffee” vs “User has a dog” |
Resolution behavior
Section titled “Resolution behavior”CONTRADICTION or UPDATE
Section titled “CONTRADICTION or UPDATE”When a conflict is detected:
- Old memory is demoted: If the old memory was core, it’s downgraded to semantic (losing its 0.60 floor).
- Old memory is marked:
contradicted_byis set to the new memory’s ID. - New memory inherits importance: It takes the maximum of its own importance and the old memory’s importance.
- Core inheritance: If the old memory was core and the conflict is a CONTRADICTION, the new memory is promoted to core.
if conflict_type in ("CONTRADICTION", "UPDATE"): # Demote old if existing.category == MemoryCategory.CORE: existing.category = MemoryCategory.SEMANTIC existing.contradicted_by = new_memory.id
# Boost new new_memory.importance = max(new_memory.importance, existing.importance) if conflict_type == "CONTRADICTION" and existing.category == MemoryCategory.CORE: new_memory.category = MemoryCategory.COREOVERLAP or NONE
Section titled “OVERLAP or NONE”No action taken. Both memories coexist.
The conflict detection prompt
Section titled “The conflict detection prompt”Does the new memory contradict or update an existing memory?
Existing memory: "{existing}"New memory: "{new}"
Respond with exactly one word: CONTRADICTION, UPDATE, OVERLAP, or NONE.- CONTRADICTION: the new memory directly negates the existing one- UPDATE: the new memory is a newer version of the same fact- OVERLAP: they cover similar ground but don't conflict- NONE: they are unrelatedPerformance considerations
Section titled “Performance considerations”Conflict detection is computationally expensive because it involves LLM calls. The system optimizes by:
- Only checking high-importance candidates (importance > 0.5 or core). Low-importance memories aren’t worth the LLM call.
- Similarity gate at 0.6. Only pairs that are semantically related are checked. This filters out the vast majority of comparisons.
- Skipping superseded and stub memories. Already-resolved conflicts aren’t re-checked.
For a typical system with 100 hot memories, a new memory might trigger 2-5 LLM calls (the high-similarity pairs from the filtered candidates). This is manageable within a normal ingestion flow.
Example flow
Section titled “Example flow”- Memory store contains: “User lives in Portland” (core, importance=0.9)
- New memory arrives: “User just moved to Seattle”
- Cosine similarity between embeddings: 0.78 (> 0.6 threshold)
- LLM call: classifies as “UPDATE”
- Resolution:
- “User lives in Portland” demoted from core to semantic, marked as contradicted
- “User just moved to Seattle” inherits importance 0.9
- Future searches will surface the Seattle memory; the Portland memory will gradually decay without the core floor protecting it.