Write path
When your app callsPOST /v1/memories/add, MemoryEngine does not immediately write raw chat text into memory.
The write path is:
- Validate tenant auth and
external_user_id - Run the quality gate
- Create an extraction job
- Extract durable memories from the conversation
- Resolve conflicts against existing memories
- Store canonical memories in PostgreSQL
- Write embeddings to Qdrant for retrieval
- Record memory versions for audit and debugging
- Run the tenant’s domain overlay if
domain_schemais enabled
job_id. Extraction runs in the background.
For example, an EdTech tenant still stores normal generic memories, but the domain overlay also updates edtech_memories with grade level, weak topics, learning style, exam context, and forgetting stages.
Read path
When your app callsPOST /v1/memories/retrieve, MemoryEngine retrieves memories and builds context that can be prepended to your model prompt.
The read path is:
- Resolve the tenant and user
- Check quota and dependency mode
- Load hot-tier memories from Redis when available
- Search vector memory for remaining slots
- Rank with semantic relevance, importance, and recency
- Filter archived and out-of-scope memories
- Build
system_prompt_addition - Prepend domain-aware context if the tenant has an active domain schema
system_prompt_addition is the safest field to pass into your LLM call.
ContextBuilder
ContextBuilder turns retrieved memories into high-quality model context. Supported formats:| Format | Use when |
|---|---|
bullets | You want prompt-ready natural-language context |
json | Your app parses memory context programmatically |
xml | You want strongly tagged context for models that follow XML well |
bullets output:
Conflict resolution
When a new extracted memory contradicts an existing one, MemoryOS resolves the conflict instead of blindly storing both. Examples:| Old memory | New memory | Result |
|---|---|---|
| User prefers JavaScript examples. | User now prefers Python examples. | Old memory can be archived or superseded |
| User works at Acme. | User left Acme and joined Northstar. | Newer factual memory wins |
exam_date, grade_level, and weak_topic route to user-session clarification. Shared institutional facts such as curriculum_standard or institution_policy route to tenant review. Unknown entities fall back to the generic router.
Resolution paths
MemoryOS uses several conflict resolution paths:| Path | When it happens | Outcome |
|---|---|---|
| Same-user automatic update | A new memory supersedes an older memory for the same user | Old memory is archived and the new memory points to the previous version |
| Same-user merge | Two memories are compatible but incomplete separately | MemoryOS stores a merged memory and archives the old version |
| Same-user reject | The new extracted memory is duplicate or lower quality | Incoming memory is rejected and not stored |
| Keep both | The memories differ by time or both are still valid | Both memories remain available with version history |
| Cross-user per-user scoped | A conflict is actually personal to each user | Conflict is ignored as not a shared-context conflict |
| Cross-user recency weighted | One shared claim is much newer than the other | Older claim is weighted down automatically |
| Cross-user confidence weighted | One shared claim has much higher confidence | Lower-confidence claim is weighted down automatically |
| User-session clarification | The conflict is personal and only the user can confirm it | A question appears in the consent app’s Pending Questions tab |
| Tenant review | The conflict is about team, organization, institution, or workspace truth | Tenant admins resolve it in the dashboard Conflicts page |
Domain overlays
Domain overlays add structured product-specific memory without changing the SDK.add() and get() for AI responses. Use optional domain helpers, such as get_edtech_profile(), only when building dashboards or analytics.
Importance scoring
Each memory has:original_importance_score: extraction-time scoreimportance_score: live score that can change with usage and decayaccess_count: retrieval countlast_accessed_at: last retrieval timestamp
Multi-provider extraction
MemoryEngine can use multiple LLM providers for extraction and conflict classification. Provider order is configured with:5xx, rate limit, or auth error, MemoryOS falls through to the next configured provider. Operator health shows each provider as CLOSED, OPEN, HALF_OPEN, or NOT CONFIGURED.