Core Concepts

Browse docs

Core Concepts

Tap to expand
Core ConceptsUpdated 2026-05-25

Scopes

How project, user, session, agent, and task scopes keep RetainDB memory isolated and useful.

Scopes decide what memory can be written and retrieved.

ScopePurposeExample
projectProduct or environment boundaryproduction, acme-support
user_idEnd-user memoryuser_123
session_idConversation or workflow memorychat_456
agent_idAgent identityplanner, builder
task_idShared work itemcheckout-redesign

Rules that avoid bugs

  • Use stable IDs from your application.
  • Do not let the browser invent tenant scope.
  • Keep project names consistent between write and search.
  • Use session scope when the same user has multiple independent conversations.
  • Use agent and task scope for multi-agent workflows.

User chat example

ts
const user = db.user("user_123");
const session = user.session("chat_456");

await session.remember("User is debugging billing webhooks.");
const { context } = await session.getContext("What are we debugging?");

Agent task example

ts
const task = db.agent("planner").task("checkout-redesign");

await task.event({
  type: "decision",
  summary: "Use hosted checkout for the first release."
});

Next: Agent Memory Bus.

Was this page helpful?

Your feedback helps us prioritize docs improvements weekly.