SmartMemory
Concepts

Assertion Challenging

Code: smartmemory/reasoning/challenger.py · Class: AssertionChallenger

SmartMemory detects contradictions between new facts and existing knowledge using a multi-method detection cascade and an auto-resolution layer. Use it to flag — or correct — factually inconsistent input as it arrives.

Detection cascade

LLM → Graph → Embedding → Heuristic

Each method runs only if the previous one did not produce a high-confidence verdict.

MethodReliabilitySpeedWhat it catches
LLM⭐⭐⭐⭐⭐SlowNuanced contradictions, context-dependent conflicts
Graph⭐⭐⭐⭐FastFunctional properties (capital, CEO, born in)
Embedding⭐⭐⭐MediumHigh similarity + opposite polarity
Heuristic⭐⭐FastObvious negations ("is" vs "is not")

Pipeline

flowchart TB
    A["💬 User Statement"] --> B["🔍 Memory Retrieval"]
    B --> C["🧠 LLM Analysis"]
    C --> D{"Conflict Detected?"}

    D -->|No| E["✅ Normal Processing"]
    D -->|Yes| F["⚠️ Conflict Analysis"]

    F --> F1["📊 Confidence Scoring"]
    F --> F2["🎯 Conflict Type Classification"]
    F --> F3["💡 Suggested Response"]

    F1 --> G["🤝 Gentle Challenge"]
    F2 --> G
    F3 --> G

    style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
    style C fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    style G fill:#e8f5e8,stroke:#388e3c,stroke-width:2px

Usage

# Challenge a new assertion explicitly
result = memory.challenge("Paris is the capital of Germany")

if result.has_conflicts:
    for conflict in result.conflicts:
        print(f"Contradicts: {conflict.existing_fact}")
        print(f"Method: {conflict.explanation}")  # [LLM], [Graph], [Embedding], etc.
        print(f"Confidence: {conflict.confidence}")

# Auto-challenge during ingestion (only fires for factual-looking content)
memory.ingest("The speed of light is 300,000 km/s")

# Force or skip explicitly
memory.ingest(content, auto_challenge=True)   # always challenge
memory.ingest(content, auto_challenge=False)  # never challenge

Smart triggering

Auto-challenge only runs for content that looks like a factual claim. Conversational, opinion, and ephemeral content is skipped to avoid false positives and unnecessary LLM cost.

Triggered ✅Skipped ❌
"X is the Y" patternsOpinions ("I think...")
Numeric claimsQuestions
"capital of", "CEO of"Greetings
Absolute claims ("always", "never")Temporal/personal ("today", "currently")

Conflict types

TypeDescriptionExample
DIRECT_CONTRADICTIONOpposite claims"X is Y" vs "X is not Y"
TEMPORAL_CONFLICTTime-based conflict"Was X" vs "Now Y"
NUMERIC_MISMATCHDifferent values"Population is 14M" vs "37M"
ENTITY_CONFUSIONSame name, different entities"Apple (fruit)" vs "Apple (company)"

Auto-resolution

Before deferring to human review, SmartMemory attempts to resolve the conflict from authoritative sources:

Wikipedia Lookup → LLM Reasoning → Grounding Check → Recency Heuristic
MethodWhat it doesConfidence
WikipediaLooks up entities, checks which fact aligns0.85
LLM ReasoningAsks the model to fact-check with reasoning0.7+
GroundingChecks existing provenance / trusted sources0.75
RecencyFor temporal conflicts, prefers recent info0.65
result = challenger.resolve_conflict(conflict, auto_resolve=True)

if result["auto_resolved"]:
    print(f"Resolved via {result['method']}: {result['evidence']}")
else:
    print("Could not auto-resolve, needs human review")

Manual resolution strategies

When auto-resolution defers, the caller picks one of:

  • KEEP_EXISTING — trust the existing fact
  • ACCEPT_NEW — replace with the new fact (decays old confidence)
  • KEEP_BOTH — store both with a conflict marker
  • DEFER — flag for human review

Behaviour notes

  • Semantic, not regex. Detection uses LLM reasoning over retrieved context, not pattern matching, so it tolerates paraphrase and surface variation.
  • Gentle by default. When a conflict surfaces during conversational ingest, the system suggests a gentle challenge rather than rejecting the input — appropriate for assistant-style products.
  • Cost-aware. The cascade short-circuits as soon as a high-confidence verdict is reached; embedding and heuristic checks are cheap, the LLM only runs when needed.

On this page