Perspective & User Memory
Two questions come up whenever several people or agents share one memory store:
- What does X know about Y? An agent that talked to Alice about Bob should answer from its own conversations, not from everything anyone said about Bob.
- What follows a user around? “I prefer TypeScript” should apply in every workspace the user works in, without leaking into other users’ results.
MemoryLayer 0.2.0 answers both with perspective (observer/subject anchors) and user-scoped memory. Both are part of core MemoryLayer.
Observer and Subject
Every memory can carry two perspective anchors:
| Field | Meaning |
|---|---|
observer_id | Who is remembering or reporting this: an agent ID, a user ID, or an email sender |
subject_id | Who or what the memory is about |
Set them on POST /v1/memories and batch creates, and filter on them in recall and reflect:
curl -X POST "$MEMORYLAYER_URL/v1/memories" \ -H "Content-Type: application/json" \ -d '{ "content": "Bob said the Q3 launch slips to October", "observer_id": "agent-sales-1", "subject_id": "Bob" }'
curl -X POST "$MEMORYLAYER_URL/v1/memories/recall" \ -H "Content-Type: application/json" \ -d '{"query": "launch timeline", "observer_id": "agent-sales-1"}'Ingestion sets these fields for you where it can. For email ingestion, the sender becomes the observer_id. With the Entity Registry enabled, observer_id is attached to the observer’s entity as a self member and subject_id as a mention.
Representations
A representation assembles what one party understands about another. It is built deterministically from the entity registry, with no LLM call and no recall:
- Observer ≠ subject. The memories the observer authored (
selfmembers) that mention the subject (mentionmembers). Memories about the subject written by other observers are excluded by design. - Observer = subject. The subject’s own self-reports.
Observations are sorted by event_time, then created_at (newest first), and truncated to limit.
Enabling
The representation endpoints are off by default and need the entity registry:
export MEMORYLAYER_ENTITY_REGISTRY_ENABLED=trueexport MEMORYLAYER_REPRESENTATION_ENABLED=trueWhile MEMORYLAYER_REPRESENTATION_ENABLED is off, both endpoints return 404. They require representation:read authorization.
POST /v1/representation
curl -X POST "$MEMORYLAYER_URL/v1/representation" \ -H "Content-Type: application/json" \ -d '{"observer": "agent-sales-1", "subject": "Bob", "limit": 20}'| Field | Default | Description |
|---|---|---|
observer | required | Observing entity’s surface name. It is resolved through the registry and never created. |
subject | required | Subject entity’s surface name |
observer_type, subject_type | — | Optional entity-type hints for resolution |
limit | 20 | Maximum observations (1–200) |
include_profile | true | Attach a compact profile |
workspace_id | session / _default | Workspace override |
The response is a Representation:
| Field | Description |
|---|---|
observer, subject | The resolved entities |
is_self | true when observer and subject are the same entity |
observations[] | memory_id, content, role (self or mention), event_time, and any carried relevance / match_signals |
profile | summary, source_memory_ids, and derived. The summary is taken from a profile-subtype memory in scope if there is one (derived: false). Otherwise it is synthesized from the top observations. |
derived_beliefs[] | Always empty on a core server. MemoryLayer Enterprise fills it with LLM-derived beliefs (statement, confidence, support_memory_ids, contradicted). |
provenance | How the scope was assembled. It also notes when a name could not be resolved. |
If either name does not resolve, the endpoint returns an empty representation rather than an error.
User-Scoped Memory
A memory’s scope decides where it lives:
| Scope | Stored in | Visible to |
|---|---|---|
workspace (default) | The caller’s workspace | Anyone who can read that workspace |
user | The _global_user workspace, partitioned by user_id | That user only, from every workspace they recall in |
Recall pulls a user’s user-scoped memories back in when the request carries a user_id and include_global_user is true (the default). Every read of _global_user is filtered by the user’s own user_id, so one user’s preferences never appear in another user’s results.
Routing Rules
On each write, the server decides the scope in this order:
scope: "user"goes to user scope. Auser_idis required, and the write is rejected without one.scope: "workspace"stays in the workspace.- With no explicit scope,
preferenceanddirectivesubtypes go to user scope whenMEMORYLAYER_USER_SCOPE_SUBTYPESis on (defaulttrue). - With no explicit scope and no subtype decision, an optional preference-vs-episodic classifier can route the memory to user scope. It runs only when
MEMORYLAYER_USER_SCOPE_AUTOCLASSIFY_ENABLED=true(defaultfalse) and the classifier’s confidence is at leastMEMORYLAYER_USER_SCOPE_AUTOCLASSIFY_THRESHOLD(default0.85). The core classifier is a conservative pattern matcher for phrases like “I prefer…” or “I always…”. MemoryLayer Enterprise can use an LLM classifier.
An implicit promotion (rule 3 or 4) with no user_id leaves the memory in the workspace.
curl -X POST "$MEMORYLAYER_URL/v1/memories" \ -H "Content-Type: application/json" \ -d '{ "content": "Prefers TypeScript and dark mode", "subtype": "preference", "scope": "user", "user_id": "alice" }'POST /v1/representation/user
Returns a user’s self-representation, built only from their _global_user memories: preferences and traits that follow them across workspaces.
curl -X POST "$MEMORYLAYER_URL/v1/representation/user" \ -H "Content-Type: application/json" \ -d '{"limit": 20}'user_id defaults to the authenticated user. Reading another user’s representation is a cross-user read and must be separately authorized. The response has user_id, observations, profile, derived_beliefs, and provenance.
Data Management
User-scoped memories live in _global_user, not in any project workspace, so deleting a project workspace leaves them in place. See Data Management & GDPR for erasure guidance.