Each memory snapshot has a revision. Updates name the revision they observed so concurrent writes cannot silently overwrite one another.
Read memory
const session = agent.session("reference-session-001");
const memory = await session.memory.get(context);
console.log(memory.revision, memory.value.nextAction);Update memory
const updated = await session.memory.update(
{
expectedRevision: memory.revision,
patch: {
goal: "Understand the current project",
findings: "The runner boundary and package contracts need review.",
decisions: "Keep the next change limited to public documentation.",
openQuestions: "Which integration should be verified first?",
nextAction: "Review the runner service example.",
linkedArtifacts: ["docs/review-notes.md"],
},
},
context,
);
console.log(updated.revision);The supported memory fields are goal, currentPlan, findings, decisions,
openQuestions, nextAction, and linkedArtifacts.
If another process updates the session first, read the newest snapshot, review the competing change, and submit an intentional patch using the new revision.
Continue with Next.js integration or the SDK reference.