# list()

Canonical URL: https://developers.iagenify.com/pt/sdk/ref/memory/list/
Language: pt

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

Ogni nota del conto, cambiata prima, ultimamente, con il suo contenuto. Questo è l'ecran que mostra l'usuario.

Status: GET /api/ai/memories · free · an array

## Parâmetros {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `limit` | integer |  | Quanti. Predefinit a `200`, che è anche il cap e il maximum un conto può tenir. |

Dando il cap e il maximum sono il mesmo numero, il predefinit restitue tutto. Non c'è pagination, perché non c'è nulla da paginare.

## Retorno {#returns}

```javascript
[
  {
    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: "…"
  }
]
```

Un array, directamente — non un envelope. Un conte senza nota da un array vazio.

## Il contenti viene con il {#content}

Diversamente da quello che il agente ottiene — que è solo l'indice — questo restitui tutto, contenuto incluso. É destinado a una persona che guarda a ciò che è ricordat de loro.

```javascript
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}`);
}
```

## Agrupamento per tipo {#group}

| tipo | Significado |
| --- | --- |
| Preferit | Como l'usuariu vor che le cose fa. |
| progetto | Algo sul lavoro in mano. |
| istu | Algo stabil e verificabile. |
| Correzione | Algo che l'agente s'erra e che si dice. |
| otre | Il predefinit quando ningun altro cadde. |

```javascript
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));
```

## Un rivisuo vale la pena di run {#review}

Memoria decae in utilit in lugar de in talla: una nota scritta a proposito di un progetto che termina è ancora led in contexto ogni vez. Guardando a ciò che non ha cambiat in un tempo longo è la versione barata de poda.

```javascript
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}`);
}
```

> **Prune a mano, o lascia l'usuario lo fa**
>
> Una nota è circa il titulari del conto, quindi cancellare uno in nome di loro è una decisione, non pulizies. Mostrando-le la lista è generalmente la mossa migliore.

- [save()](/pt/sdk/ref/memory/save): Scriviu o sostituiu uno.
- [delete()](/pt/sdk/ref/memory/delete): Rimuovendo uno per nome.

```python
[
    {
        "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": "…",
    }
]
```

```python
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']}")
```

```python
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"])
```

```python
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']}")
```
