MemgraphAI

Core Concepts

Memgraph organizes AI agent memory into a multi-layer pipeline. Each layer serves a specific purpose in transforming raw interactions into usable knowledge.

Events
Raw input
Episodes
Temporal clusters
Beliefs
Extracted facts
Context
Agent prompt

Events

Events are the raw interactions your application streams into Memgraph. Every user message, tool call, agent response, or system log is an event.

event_type

Type of event: user_message, agent_response, tool_call, system_log

content

JSON payload with the event data (e.g., {text: '...'})

thread_id

Groups events into conversations. Events in the same thread form a sequence.

user_id

The end-user this event belongs to. Used for per-user memory scoping.

agent_id

The AI agent that produced or received this event.

tenant_id

Your tenant (workspace). All queries are scoped by this.

Events are append-only. Once ingested, they cannot be modified. They are the source of truth for everything downstream.

Episodes

Episodes are temporal clusters of events. Memgraph automatically segments a continuous stream of events into discrete episodes — typically one per conversation session or task.

summary

LLM-generated summary of what happened in this episode.

tags

Auto-extracted topic tags (e.g., ['deployment', 'kubernetes']).

outcome

How the episode ended: completed, abandoned, escalated.

consolidation_status

pending → processing → consolidated. Tracks dreaming progress.

Episodes are the bridge between raw events and extracted knowledge. During Cognitive Dreaming, pending episodes are processed to extract beliefs.

Beliefs

Beliefs are the long-term memory layer — semantic facts extracted from episodes or stored directly. They represent what Memgraph "knows" about a user, with confidence scores and versioning.

key

What the belief is about (e.g., 'preferred_language').

value

The actual knowledge (e.g., 'Python 3.12').

confidence

0.0 to 1.0. How certain this belief is. Decays or strengthens over time.

belief_type

fact (verified), belief (inferred), preference (user stated), tenet (system rule).

epistemic_status

active, superseded, contradicted, retracted. Tracks belief lifecycle.

domain

Category: settings, workflow, personal, technical, etc.

subject_id

Who this belief is about — typically a user_id.

Beliefs support versioning. When a belief is updated, the old version is marked as superseded and a new version is created. You can trace the full evolution chain via the audit timeline.

Context

Context is the output of the memory pipeline — a synthesized packet of relevant beliefs and episode summaries that you inject into your agent's system prompt. When you call POST /v1/context or client.search(), Memgraph performs:

  1. Vector search across beliefs using your query embedding
  2. Confidence filtering to exclude low-confidence or stale beliefs
  3. Episode matching for relevant conversation summaries
  4. Formatting into a prompt-ready text block

Cognitive Dreaming

Cognitive Dreaming is Memgraph's background consolidation process — inspired by how human brains consolidate memories during sleep. A background worker periodically:

  1. Picks up episodes with consolidation_status = pending
  2. Uses an LLM to analyze the episode and extract beliefs
  3. Creates or updates beliefs (upsert by subject_id + key)
  4. Generates vector embeddings for semantic search
  5. Marks the episode as consolidated

Dreaming requires an OPENAI_API_KEY environment variable for the LLM calls. You can also trigger dreaming manually via POST /v1/dreaming/trigger.

Documents

Documents are supplementary knowledge you upload into Memgraph — PDFs, text files, or web content. They are chunked, embedded, and included in context retrieval alongside beliefs.

POST /v1/documents

Create a document from text content.

POST /v1/documents/upload

Upload a file (PDF, TXT, etc.).

POST /v1/documents/link

Ingest content from a URL.

Knowledge Graph

Memgraph builds a knowledge graph connecting users, beliefs, episodes, and documents through semantic relationships. The graph endpoint (GET /v1/graph) returns nodes and edges for visualization in the Memory Map dashboard.