WOLBΛRG

getRelated()

Traverse graph relations from a memory id and return related MemoryRecord rows.

Signature

getRelated(
  memoryId: string,
  options?: {
    relation?: string;
    depth?: number;           // default 1, max 16
    direction?: "in" | "out" | "both";
  },
): Promise<MemoryRecord[]>

Requires a configured graph provider.

What it does

Walks edges from memoryId and returns related memories. The facade re-hydrates rows from the storage backend when possible so you get full content, not only graph stubs.

Portable across SQLite and Neo4j — see Portability.

Example

const neighbors = await ctx.getRelated(memoryId, {
  relation: "related_to",
  depth: 2,
  direction: "out",
});

for (const m of neighbors) {
  console.log(m.id, m.content.text);
}

Options

FieldDefaultDescription
relationallRestrict to one relation name
depth1Hops to walk (clamped to 16)
direction"both""in" | "out" | "both"

For recall-time attachment without a separate call, use recall({ includeGraph: true }).