Skip to content

Reflect

Reflect is the “thinking” operation. It analyzes the knowledge graph and improves it by organizing, synthesizing, and restructuring.

[1. Discover] → find orphans, weak links
[2. Cluster] → group by embedding similarity
[3. Gather Context] → load existing Domains and Concepts
[4. Analyze (LLM)] → decide per cluster
[5. Persist] → apply changes to graph

Find memories that need attention: orphaned facts without parent concepts, weak or missing links between related memories.

Group related memories by embedding similarity. Memories that are semantically close are placed in the same cluster.

Load existing Domains and Concepts so the LLM knows what organizational structure already exists.

For each cluster, the LLM decides:

  • Link facts to an existing concept
  • Create a new concept or domain
  • Synthesize new memories from patterns
  • Restructure relationship edges

Apply all changes to the knowledge graph atomically.

Reflect builds and maintains the layer hierarchy:

"Programming" (Domain)
└── "Type Systems" (Concept)
├── "Haskell has ADTs" (Fact)
└── "Rust has ownership" (Fact)

Reflect can draw inferences from existing knowledge:

  • Fact A: “All mammals are warm-blooded”
  • Fact B: “Whales are mammals”
  • Synthesized: “Whales are warm-blooded” (inferred)
  • After bulk ingestion of many facts
  • Periodic maintenance to organize accumulated knowledge
  • When recall quality degrades due to unorganized memories
Terminal window
curl -X POST https://api.memlayer.dev/api/v1/reflect \
-H "Content-Type: application/json" \
-d '{"query": "programming", "dry_run": false}'
FieldTypeRequiredDescription
querystringNoOnly consolidate memories matching this topic
dry_runboolNoPreview operations without applying (default: false)
thresholdfloatNoMinimum similarity for linking facts
cluster_thresholdfloatNoMinimum similarity for clustering
limitintNoMaximum facts to process