scope object. Scope is the routing key that determines which partition of the memory store is read from and written to. Two requests with different scopes are completely isolated from each other: a search in scope { user: 'alice' } will never return memories stored under { user: 'bob' }, even on the same Core instance. This isolation is enforced by the server, not just the SDK.
The Four Scope Fields
The end-user identifier. This is the most commonly set field and should be a stable, unique ID for the person interacting with your application — for example, a database primary key or auth provider subject claim. Do not use display names or email addresses, which can change.
The agent or assistant identifier. Use this to separate memories by which agent variant stored them — for example,
'customer-support', 'coding-assistant', or 'research-agent'. Useful when multiple agents share memory for the same user but should maintain independent memory sets.An application or project namespace. Use this to scope memories to a specific product, tenant, or environment within a larger system — for example,
'my-app', 'acme-corp', or 'staging'.A specific conversation thread or session identifier. Thread scope is the most granular: memories stored with a thread ID are only retrieved when searching that exact thread. Use this for session-scoped memory that should not bleed across conversations.
TypeScript Type
Common Scope Patterns
Different applications call for different combinations of scope fields. The examples below cover the most frequently used patterns:Multi-Tenant Safety
Scope is the only memory boundary in AtomicMemory. There is no additional row-level access control layer — if two tenants share the sameuser value, their memories will be mixed. You must ensure that user identifiers are globally unique across your entire tenant population.
Scope in Framework Adapters
When AtomicMemory is integrated through a framework adapter (LangChain, Vercel AI SDK, etc.), scope is typically fixed at factory time when the adapter is configured. This means the agent or tool cannot change its own scope at runtime — it is bound to the scope passed during initialisation. This design is intentional. Fixing scope at factory time means:- An agent cannot accidentally or maliciously read another user’s memories by passing a different
uservalue. - Scope is auditable — you can trace which scope was in effect for a given agent instance from your application code, without needing to inspect every individual memory call.
- Your authorisation logic lives in one place (the factory / initialisation layer), not scattered across every memory operation.