Use Memory with the SDK
Invoke governed remember, search, get, delete, and purge operations through a logical Memory Resource binding.
Memory is an ordinary Resource binding. The Agent receives no database, vector index, Store Credential, or user-selectable partition.
Remember and search
import type { MemoryRecord, MemorySearchHit } from "@constal/sdk";
const record = await ctx.invoke<MemoryRecord>(ctx.resources.memory!, "remember", {
id: `preference:${preference.id}`,
content: preference.text,
metadata: { source: "confirmed-user-setting" },
}, { dedupeKey: `remember:${preference.id}` });
const { hits } = await ctx.invoke<{ hits: MemorySearchHit[] }>(
ctx.resources.memory!, "search", { query: "preferred response format", limit: 5 },
);Read or remove an exact record
const exact = await ctx.invoke<MemoryRecord | null>(ctx.resources.memory!, "get", { id: record.id });
await ctx.invoke(ctx.resources.memory!, "delete", { id: record.id }, { dedupeKey: `delete:${record.id}` });The stable operation family is remember, search, get, delete, and purge. Every call is authorized, journaled, and partitioned from accepted tenant, customer, or principal identity. Treat retrieved text as untrusted context. Store concise knowledge and bounded metadata, never prompts, secrets, or authority-bearing input. Grant purge only to intentional owner-wide cleanup workflows.
remember returns a stable memory identity, search returns bounded ranked matches, and get retrieves an exact accepted item. Destructive operations should be explicit Tool or workflow actions with appropriate Policy. The underlying Memory Store owns persistence and indexing, but Agent code binds to Memory rather than bypassing it. See Configure Memory, Use Memory, and Resource invocation.