Write path
POST /v1/memories/add triggers this sequence:
- Authenticate tenant and resolve
external_user_id - Run quality gate (L1 rate → L2 quality → L3 dedup → L4 budget)
- Create extraction job
- Extract durable memories via LLM
- Resolve conflicts against existing memories
- Store in PostgreSQL
- Write embeddings to Qdrant
- Record version history
- Run domain overlay if
domain_schemais enabled
job_id immediately. Extraction is async.
With the EdTech schema enabled, the domain overlay also updates edtech_memories with grade level, weak topics, learning style, and exam context alongside the normal memory path.
Read path
POST /v1/memories/retrieve triggers this sequence:
- Resolve tenant and user
- Check quota and dependency mode
- Load hot-tier memories from Redis
- Search Qdrant for remaining slots
- Rank by semantic relevance, importance, and recency
- Filter archived and out-of-scope memories
- Build
system_prompt_addition - Prepend domain-aware context if a domain schema is active
Context formats
system_prompt_addition comes in three formats:
Example
bullets output:
Conflict resolution
When a new memory contradicts an existing one, MemoryEngine resolves the conflict rather than storing both blindly.
All conflict changes appear in version history. Routing is domain-aware — personal student facts go to user-session clarification, workspace-level facts go to tenant review.
Resolution paths in full:
Importance scoring
Each memory tracks:original_importance_score— set at extraction timeimportance_score— live score, changes with usage and decayaccess_count— how many times this memory has been retrievedlast_accessed_at— last retrieval timestamp