api.memory

list()

api.memory.list({ limit }) → Promise<Memory[]>

Every note on the account, most recently changed first, with its content. This is the screen you show the user.

GET /api/ai/memoriesfreean array
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Parameters

limitinteger

How many. Defaults to 200, which is also the cap and the maximum a account can hold.

Since the cap and the maximum are the same number, the default returns everything. There is no pagination because there is nothing to paginate.

Returns

[
  {
    id: "…",
    name: "tone-of-voice",
    description: "How this user wants to be written to",
    content: "Prefers short, direct answers in French.",
    type: "preference",
    source: "user",
    createdAt: "…",
    updatedAt: "…"
  }
]
[
    {
        "id": "…",
        "name": "tone-of-voice",
        "description": "How this user wants to be written to",
        "content": "Prefers short, direct answers in French.",
        "type": "preference",
        "source": "user",
        "createdAt": "…",
        "updatedAt": "…",
    }
]

An array, directly — not an envelope. An account with no notes gives an empty array.

The content comes with it

Unlike what the agent gets — which is the index alone — this returns everything, content included. It is meant for a person looking at what is remembered about them.

const notes = await api.memory.list();

for (const n of notes) {
  console.log(`${n.name} · ${n.type} · by ${n.source}`);
  console.log(`  ${n.description}`);
  console.log(`  ${n.content}`);
}
notes = api.memory.list()

for n in notes:
    print(f"{n['name']} · {n['type']} · by {n['source']}")
    print(f"  {n['description']}")
    print(f"  {n['content']}")

Grouping by type

typeMeans
preferenceHow the user wants things done.
projectSomething about the work in hand.
factSomething stable and verifiable.
correctionSomething the agent got wrong and was told about.
otherThe default when nothing else fits.
const byType = new Map();
for (const n of await api.memory.list()) {
  byType.set(n.type, [...(byType.get(n.type) || []), n]);
}

// Corrections are the ones worth reviewing: each is something that went wrong once.
byType.get("correction")?.forEach((n) => console.log(n.name, "·", n.content));
from collections import defaultdict

by_type = defaultdict(list)
for n in api.memory.list():
    by_type[n["type"]].append(n)

# Corrections are the ones worth reviewing: each is something that went wrong once.
for n in by_type["correction"]:
    print(n["name"], "·", n["content"])

A review worth running

Memory decays in usefulness rather than in size: a note written about a project that ended is still read into context every time. Looking at what has not changed in a long while is the cheap version of pruning.

const notes = await api.memory.list();
const quarter = Date.now() - 90 * 24 * 60 * 60 * 1000;

const old = notes.filter((n) => Date.parse(n.updatedAt) < quarter && n.type === "project");

for (const n of old) {
  console.log(`still remembered, last touched ${n.updatedAt}: ${n.name} — ${n.description}`);
}
from datetime import datetime, timedelta, timezone

notes = api.memory.list()
quarter = datetime.now(timezone.utc) - timedelta(days=90)

old = [n for n in notes
       if n["type"] == "project" and datetime.fromisoformat(n["updatedAt"].replace("Z", "+00:00")) < quarter]

for n in old:
    print(f"still remembered, last touched {n['updatedAt']}: {n['name']} — {n['description']}")
Prune by hand, or let the user do it

A note is about the account holder, so deleting one on their behalf is a decision, not housekeeping. Showing them the list is usually the better move.