Core Concepts

Browse docs

Core Concepts

Tap to expand
Core ConceptsUpdated 2026-05-25

Memory Quality

How to make RetainDB memory useful instead of noisy.

Good memory is not "store everything." Good memory is storing the facts, preferences, decisions, constraints, and events that should change future behavior.

Store high-signal information

Good memories:

  • "User prefers TypeScript examples."
  • "Customer is migrating from a legacy billing system."
  • "Planner chose hosted checkout for v1 to avoid PCI scope."
  • "Builder hit a webhook signature failure in test mode."

Noisy memories:

  • full terminal output
  • repeated assistant explanations
  • every token of a long transcript
  • temporary facts that expire after one turn

Retrieve small context

Use a small top_k first. A few relevant memories are usually better than a long memory dump.

ts
const { context } = await db
  .user("user_123")
  .getContext("How should I answer this billing question?");

Separate memory from project knowledge

Use memory for user, session, and agent state. Use context query for indexed project knowledge such as docs, repos, and help center content.

Use scope as a quality control

Most "bad memory" bugs are actually scope bugs:

  • wrong user_id
  • missing session_id
  • reused task_id
  • different project between write and search

Review and delete

For production apps, expose controls to view and delete remembered facts. That builds trust and keeps memory clean over time.

Next: Scopes.

Was this page helpful?

Your feedback helps us prioritize docs improvements weekly.