Skip to Content

Interface Memory

One memory a search returned.

A memory is the container that makes knowledge findable, not the finding itself — that lives one level down in Memory.insights.

When Memory.reference is set the memory carries no insights, and iterating them anyway reads as "nothing matched" when something did. Fetch it with MemoryOperations.getMemory by its own idx, never the one in reference.

None of the intents is "the one that matched": a memory is retrieved whole, so they say what it answers rather than why it came back this time.

for (const memory of result.memories) {
const full =
memory.reference === null
? memory
: await client.memory.getMemory(memory.idx)
for (const insight of full.insights) {
console.log(insight.title, insight.content)
}
}
interface Memory {
    idx: string;
    kind: string;
    timesServed: number;
    intents: readonly string[];
    insights: readonly Insight[];
    reference: string | null;
    feedback: (rating: MemoryFeedback) => Promise<FeedbackEntry>;
}
Index
idx: string

The handle addressing this memory.

kind: string

The kind of memory, when the service names one.

timesServed: number

How often it has been returned to anyone.

intents: readonly string[]

Questions it has been retrieved by before, oldest first.

insights: readonly Insight[]

The findings it holds.

reference: string | null

An earlier idx in this session that already carried this content.

When set, the insights are empty: fetch the memory by its own idx, not by this one, so a later rating stays with the search being worked in.

feedback: (rating: MemoryFeedback) => Promise<FeedbackEntry>

Rate this memory, using the session it was found in.

A shortcut for MemoryOperations.shareFeedback with a single FeedbackRating built from this memory's own idx.

Bound to this memory at conversion time, which means a Memory is no longer a plain data record: structuredClone(memory) throws, so a SearchResult carrying one cannot be posted to a worker or structurally cloned. JSON.stringify drops the function silently and works as before.

MemcoInvalidRequestError If this memory was fetched by the top-level MemoryOperations.getMemory (not through a MemoryOperations.withSession/MemoryOperations.startSession session, and not found by a search): there is no session to record the rating against, and this fails exactly as calling shareFeedback with a blank sessionId would.

await result.memories[0].feedback({ relevant: true, correct: true })