SmartMemory
Concepts

Assertion Challenging

๐Ÿ“š Repository: smartmemory-ai/smart-memory ๐Ÿ› Issues: Report bugs or request features 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.
  • Decision Memory โ€” first-class decisions with their own contradict/supersede lifecycle
  • Opinions & Observations โ€” synthesis from supporting evidence (the inverse of contradiction)
  • Inference Engine โ€” broader reasoning surface that the challenger sits inside

On this page