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 โ HeuristicEach method runs only if the previous one did not produce a high-confidence verdict.
| Method | Reliability | Speed | What it catches |
|---|---|---|---|
| LLM | โญโญโญโญโญ | Slow | Nuanced contradictions, context-dependent conflicts |
| Graph | โญโญโญโญ | Fast | Functional properties (capital, CEO, born in) |
| Embedding | โญโญโญ | Medium | High similarity + opposite polarity |
| Heuristic | โญโญ | Fast | Obvious 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 challengeSmart 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" patterns | Opinions ("I think...") |
| Numeric claims | Questions |
| "capital of", "CEO of" | Greetings |
| Absolute claims ("always", "never") | Temporal/personal ("today", "currently") |
Conflict types
| Type | Description | Example |
|---|---|---|
DIRECT_CONTRADICTION | Opposite claims | "X is Y" vs "X is not Y" |
TEMPORAL_CONFLICT | Time-based conflict | "Was X" vs "Now Y" |
NUMERIC_MISMATCH | Different values | "Population is 14M" vs "37M" |
ENTITY_CONFUSION | Same 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| Method | What it does | Confidence |
|---|---|---|
| Wikipedia | Looks up entities, checks which fact aligns | 0.85 |
| LLM Reasoning | Asks the model to fact-check with reasoning | 0.7+ |
| Grounding | Checks existing provenance / trusted sources | 0.75 |
| Recency | For temporal conflicts, prefers recent info | 0.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 factACCEPT_NEWโ replace with the new fact (decays old confidence)KEEP_BOTHโ store both with a conflict markerDEFERโ 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.
Related
- 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