build

Add session memory

Store versioned findings, decisions, questions, next actions, and artifact links for later turns in one session.

SDKbeginner0.7.0 Stable
Verified 2026-07-20View sourceReport a docs issue

Each memory snapshot has a revision. Updates name the revision they observed so concurrent writes cannot silently overwrite one another.

Read memory

TypeScript
const session = agent.session("reference-session-001");
const memory = await session.memory.get(context);
 
console.log(memory.revision, memory.value.nextAction);

Update memory

TypeScript
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.