update()
Explicitly update an existing memory by id — content and/or metadata — returning RememberResult.
Signature
update(options: {
id: string;
content?: { text: string };
metadata?: Record<string, unknown>;
}): Promise<RememberResult>
interface RememberResult extends MemoryRecord {
action: "created" | "updated";
}Example
const result = await ctx.update({
id: memoryId,
content: { text: "User prefers dark mode (confirmed)" },
metadata: { editedBy: "admin", editedAt: new Date().toISOString() },
});
console.log(result.action); // "updated"Behavior
- Replaces content when provided (re-embeds).
- Merges metadata when provided (shallow).
- Emits history
"updated"and subscribe"update". - Prefer automatic dedupe / upsert when the agent restates facts without knowing the id.