Memory

Consistency Check

The consistency checker scans across all memory tiers to detect contradictions — facts in session memory that conflict with knowledge base entries, or profile data that contradicts graph nodes. Contradictions are flagged with a confidence score and optionally auto-resolved according to a configurable resolution mode. This keeps the agent's memory coherent as knowledge evolves over time.

How it works

A consistency check runs in three stages:

  1. Cross-tier comparison — For each fact-bearing entry in session memory, daily notes, and the user profile, the checker queries the knowledge base and graph tier for semantically similar statements. Pairs with cosine similarity above 0.75 are compared for logical consistency.
  2. Contradiction scoring — Each potentially conflicting pair is passed to a lightweight classification model that assigns a contradiction confidence score between 0 and 1. Pairs below 0.6 are treated as non-contradictory and skipped.
  3. Resolution — Pairs at or above the contradiction threshold are either resolved automatically (if autoResolve is not flag-for-review) or written to the contradiction log for manual review.

Running a consistency check

Start a check

bash
POST /memory/consistency-check
{
  "workspaceId": "ws_xyz789",
  "userId": "user_abc123"
}

# Response:
# { "checkId": "check_abc123", "status": "running" }

Get results

bash
GET /memory/consistency-check/check_abc123

# Response:
# {
#   "checkId": "check_abc123",
#   "status": "complete",
#   "contradictions": [
#     {
#       "type": "factual-conflict",
#       "tierA": "session",
#       "tierB": "knowledge-base",
#       "description": "Session states Alex joined in 2023; knowledge base records 2022.",
#       "confidence": 0.88,
#       "resolution": "pending"
#     }
#   ]
# }

Contradiction types

TypeDescriptionExample
factual-conflictTwo entries assert different values for the same factSession says Alex joined in 2023; knowledge base records 2022
temporal-conflictAn entry describes a state that is inconsistent with a more recent entryA daily note from January says ProjectX is active; a March note says it was cancelled
identity-conflictProfile data or a graph node attributes different properties to the same entityUser profile says preferred language is TypeScript; graph node says JavaScript

Auto-resolution modes

ModeBehavior
keep-newestThe entry with the most recent timestamp is treated as authoritative. The older conflicting entry is marked as superseded.
keep-highest-confidenceThe entry with the higher confidence score is retained. Useful when timestamps are unreliable or when source quality varies significantly.
flag-for-reviewNo automatic resolution is applied. All contradictions are written to the log and surfaced as notifications for a human or agent to resolve.

Configuration

yaml
settings:
  memory:
    consistencyCheck:
      enabled: true
      autoResolve: keep-newest    # keep-newest | keep-highest-confidence | flag-for-review
      schedule: "0 3 * * *"      # Daily at 3 AM (cron syntax)

To disable the scheduled run and trigger checks on demand only, set enabled: false and use the POST /memory/consistency-check endpoint directly.

💡Use flag-for-review during initial deployment to build an understanding of where contradictions most commonly arise before trusting automatic resolution on production memory.