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:
| Format | Use when |
|---|---|
bullets | Prompt-ready natural language — the default |
json | Your app parses memory context programmatically |
xml | Models that parse XML tags precisely |
bullets output:
Conflict resolution
When a new memory contradicts an existing one, MemoryEngine resolves the conflict rather than storing both blindly.| Old memory | New memory | Resolution |
|---|---|---|
| User prefers JavaScript examples. | User now prefers Python examples. | Old archived, new stored |
| User works at Acme. | User left Acme and joined Northstar. | Newer factual memory wins |
| Path | Trigger | Outcome |
|---|---|---|
| Automatic update | New memory supersedes older one | Old archived, new stored with previous_version_id |
| Merge | Two memories are compatible but incomplete | Merged memory stored, old archived |
| Reject | Duplicate or lower quality | Incoming not stored |
| Keep both | Both still valid | Both kept with version history |
| Cross-user recency | One claim is much newer | Older claim weighted down |
| Cross-user confidence | One claim has much higher confidence | Lower-confidence claim weighted down |
| User clarification | Personal conflict, only user can confirm | Question surfaced on next get() via clarification_question |
| Tenant review | Workspace or institution truth | Tenant resolves in dashboard Conflicts page |
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