Skip to content

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:

FieldMeaning
observer_idWho is remembering or reporting this: an agent ID, a user ID, or an email sender
subject_idWho or what the memory is about

Set them on POST /v1/memories and batch creates, and filter on them in recall and reflect:

Terminal window
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 (self members) that mention the subject (mention members). 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:

Terminal window
export MEMORYLAYER_ENTITY_REGISTRY_ENABLED=true
export MEMORYLAYER_REPRESENTATION_ENABLED=true

While MEMORYLAYER_REPRESENTATION_ENABLED is off, both endpoints return 404. They require representation:read authorization.

POST /v1/representation

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/representation" \
-H "Content-Type: application/json" \
-d '{"observer": "agent-sales-1", "subject": "Bob", "limit": 20}'
FieldDefaultDescription
observerrequiredObserving entity’s surface name. It is resolved through the registry and never created.
subjectrequiredSubject entity’s surface name
observer_type, subject_type—Optional entity-type hints for resolution
limit20Maximum observations (1–200)
include_profiletrueAttach a compact profile
workspace_idsession / _defaultWorkspace override

The response is a Representation:

FieldDescription
observer, subjectThe resolved entities
is_selftrue when observer and subject are the same entity
observations[]memory_id, content, role (self or mention), event_time, and any carried relevance / match_signals
profilesummary, 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).
provenanceHow 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:

ScopeStored inVisible to
workspace (default)The caller’s workspaceAnyone who can read that workspace
userThe _global_user workspace, partitioned by user_idThat 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:

  1. scope: "user" goes to user scope. A user_id is required, and the write is rejected without one.
  2. scope: "workspace" stays in the workspace.
  3. With no explicit scope, preference and directive subtypes go to user scope when MEMORYLAYER_USER_SCOPE_SUBTYPES is on (default true).
  4. 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 (default false) and the classifier’s confidence is at least MEMORYLAYER_USER_SCOPE_AUTOCLASSIFY_THRESHOLD (default 0.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.

Terminal window
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.

Terminal window
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.