Reflect
Reflect is the “thinking” operation. It analyzes the knowledge graph and improves it by organizing, synthesizing, and restructuring.
Data Flow
Section titled “Data Flow”[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 graphDiscover
Section titled “Discover”Find memories that need attention: orphaned facts without parent concepts, weak or missing links between related memories.
Cluster
Section titled “Cluster”Group related memories by embedding similarity. Memories that are semantically close are placed in the same cluster.
Gather Context
Section titled “Gather Context”Load existing Domains and Concepts so the LLM knows what organizational structure already exists.
Analyze
Section titled “Analyze”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
Persist
Section titled “Persist”Apply all changes to the knowledge graph atomically.
Semantic Hierarchy
Section titled “Semantic Hierarchy”Reflect builds and maintains the layer hierarchy:
"Programming" (Domain) └── "Type Systems" (Concept) ├── "Haskell has ADTs" (Fact) └── "Rust has ownership" (Fact)Synthesis
Section titled “Synthesis”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)
When to Use
Section titled “When to Use”- After bulk ingestion of many facts
- Periodic maintenance to organize accumulated knowledge
- When recall quality degrades due to unorganized memories
curl -X POST https://api.memlayer.dev/api/v1/reflect \ -H "Content-Type: application/json" \ -d '{"query": "programming", "dry_run": false}'| Field | Type | Required | Description |
|---|---|---|---|
query | string | No | Only consolidate memories matching this topic |
dry_run | bool | No | Preview operations without applying (default: false) |
threshold | float | No | Minimum similarity for linking facts |
cluster_threshold | float | No | Minimum similarity for clustering |
limit | int | No | Maximum facts to process |