Skip to main content

Memory Layer

The Memory Layer automatically extracts discrete facts from your documents and organizes them into a structured knowledge graph of entities and relationships. Think of it as turning unstructured documents into a queryable knowledge base.

Overview

Facts

Atomic statements extracted from documents. Typed, confidence-scored, and temporally aware.Example: “The API rate limit is 100 req/min”

Entities

People, organizations, projects, and concepts referenced by facts. Automatically deduplicated across documents.Example: Acme Corp (resolved from “Acme”, “Acme Corporation”)

How It Works

1

Document Ingested

A document completes normal ingestion (chunking, embedding, classification).
2

Fact Extraction

An async memory worker sends the document content to Grok for fact extraction. Each fact is typed (fact, preference, episode, decision) and confidence-scored.
3

Entity Resolution

Extracted entity mentions are resolved against existing entities using HMAC-based exact matching and type-aware deduplication.
4

Relationship Discovery

New facts are compared against existing facts sharing the same entities. Relationships (updates, extends, derives, contradicts) are discovered via LLM comparison.

Fact Types

API Endpoints

List Entities

Response:

Get Entity Facts

Trigger Fact Extraction

Manually re-extract facts from a completed document:
Returns 202 Accepted with extraction status.

Query with Facts

Include facts in normal query responses:
See Querying with Facts for response format details.

MCP Tools

The following MCP tools are available for the Memory Layer: See MCP Integration for configuration.

CLI Commands

See CLI for full command reference.

Encryption

All fact content and entity names are encrypted at rest using the tenant’s DEK (same envelope encryption as documents). Structural metadata (fact_type, confidence, is_latest, timestamps) remain in plaintext for filtered queries. Entity deduplication uses HKDF-derived HMAC hashes — no plaintext comparison needed.