Guides

Shared Memory

Patterns for multi-agent shared semantic memory.

One instance, many agents

The simplest architecture is a single SDK instance and SQLite file. Agents differ only by the agent string on write.

When to isolate

  • Use filter.agent for private recalls
  • Omit the filter for organization-wide shared search
  • Use separate organization values for hard tenancy

Example

typescripttypescript
await ctx.remember({
  agent: "researcher",
  content: { text: "Customer prefers monthly invoices." },
});

await ctx.remember({
  agent: "support",
  content: { text: "Escalations should include invoice IDs." },
});

// Shared across agents
const shared = await ctx.recall({ query: "invoices", topK: 5 });

// Support-only
const supportOnly = await ctx.recall({
  query: "escalations",
  filter: { agent: "support" },
});