Skip to content
Docs

9 results

SDK guides

Store and recall memory

Seren Memory gives an agent two things: a private second brain it can write, review, and recall, and governed organizational knowledge it can read. Each is protected by its own access rules and scoped to you.

Step 1

Write to private memory

Store durable facts an agent should carry across runs, such as preferences, decisions, verified fixes, and reusable procedures. Every write is tied to the authenticated user and organization. Use the default active lifecycle for normal memory, draft for unreviewed or derived material, and canonical for facts that have been reviewed and should not be replaced automatically.

Store a memory (TypeScript)
import { serenMemoryRemember } from "@serendb/sdk";

const { data, error } = await serenMemoryRemember({
  body: {
    content: "The release approval owner is the on-call lead.",
    memory_type: "semantic",
    lifecycle_status: "canonical",
    importance: 4,
  },
});
if (error) throw error;

Step 2

Recall it for a task

Recall retrieves the memories most relevant to a query across semantic, keyword, ranking, and connection signals. Optional time bounds narrow the search to a period. Convert phrases such as "last week" into explicit UTC created_after and created_before values before calling recall. Hybrid recall falls back to keyword retrieval automatically when semantic search is temporarily unavailable; inspect the returned signals if the caller needs to explain degraded recall.

Recall relevant memories (TypeScript)
import { serenMemoryRecall } from "@serendb/sdk";

const { data, error } = await serenMemoryRecall({
  body: {
    query: "release approval process",
    limit: 5,
    created_after: "2026-06-01T00:00:00Z",
  },
});
if (error) throw error;

console.log(data.data.memories);
console.log(data.data.signals.semantic_available);

Step 3

Ingest source-managed notes

Use the document ingestion operation for notes that remain owned by another source. Seren Notes already uses ProseMirror and can provide its document directly. A Notion connector should convert page blocks to ProseMirror, keep connector credentials and sync state outside memory content, and use the Notion page ID as the stable external source ID. Re-ingesting a newer source revision updates the same memory and preserves earlier revisions. Change a managed note by re-ingesting its source; direct updates and appends are rejected.

Ingest a connected note (TypeScript)
import { serenMemoryIngestDocument } from "@serendb/sdk";

const { data, error } = await serenMemoryIngestDocument({
  body: {
    memory_type: "semantic",
    source_kind: "notion",
    source_external_id: "page_abc123",
    source_revision: "2026-07-13T14:30:00Z",
    source_uri: "https://www.notion.so/page_abc123",
    document: {
      type: "doc",
      content: [
        {
          type: "paragraph",
          content: [{ type: "text", text: "Release approval belongs to the on-call lead." }],
        },
      ],
    },
  },
});
if (error) throw error;

console.log(data.data.action);

Step 4

Read governed knowledge

Organizational knowledge is the separate, read-only surface for curated facts. Start by listing the knowledge domains available to the current user and agent, then pass the chosen domain_id to search, entity, and operation requests. Omitting it selects the default organization-visible domain. Agents can also follow connections between related facts inside the domain, and only inside the domain.

Restricted domains use direct grants rather than keywords. A human request needs a user grant. An agent request needs both a grant for the authenticated user and a reader grant for the authenticated agent. For example, granting an engineering user access to engineering knowledge does not grant that user or their agent access to a restricted financial domain. Domain classification is descriptive metadata and is never used as an authorization shortcut.

Organization owners and administrators create domains. Each domain's owner then controls direct grants, and every domain or grant change is recorded for audit. Memory data is encrypted in transit and at rest, with dedicated organization encryption keys for published knowledge.

Step 5

Rely on the isolation

Private memory is always restricted to the authenticated user and organization. Governed knowledge is also organization-scoped, then separated again by authorized knowledge domain. Each domain is searched independently, so a search of financial knowledge can never return engineering knowledge, and vice versa. Source-managed notes stay private memory unless a human deliberately curates information into an appropriate organizational domain. That separation lets an agent accumulate its own working context while reading permitted knowledge without silently promoting personal notes, transcripts, or restricted facts.