# Memory

Give workflows short-term conversation memory and consented long-term memory, with retention, namespaces, inspection and deletion.

Source: https://glamorous-boar.cloudvent.net/memory/

---

AgenticMind keeps two kinds of memory apart, because they have different privacy and lifetime needs.

| | Conversation state (short-term) | Long-term memories |
|---|---|---|
| **What** | Ordered `{role, content}` turns | Individual facts ("prefers window seats") |
| **Keyed by** | `conversation_id` (chosen by the client) | `namespace` (e.g. one per end user) |
| **Written by** | **Save Conversation Turn** | **Remember**, or the **Memory Tool** in `save` mode |
| **Read by** | **Conversation History** → Agent `history` input | **Recall**, or the **Memory Tool** in `recall` mode |
| **Default retention** | 30 days | 365 days |
| **Consent** | Stored only where a graph contains Save Conversation Turn | Requires an explicit `consent` value of `true` |

Both are scoped to the project; nothing is shared between projects.

## Build a chat assistant that remembers

The *Assistant with memory* template wires this:

1. **Manual Inputs**: `question`, `conversation_id` and `memory_consent` (Boolean). Chat fills `conversation_id` per thread and `memory_consent` from the *Remember facts I share* toggle (off by default).
2. **Conversation History** loads the last `max_turns` (10) messages within `max_chars` (8000) and feeds the Agent's `history` input.
3. **Memory Tool** in `recall` mode lets the agent search memories before saying it does not know something.
4. **Memory Tool** in `save` mode, with `consent` wired from `memory_consent`, lets the agent store facts. If consent is false, the tool refuses and the model is told why.
5. **Agent** answers.
6. **Save Conversation Turn** appends the question and the answer.

Try it: in Chat say *My name is Priya and I'm allergic to peanuts*, with the toggle on. Click **New chat** and ask *What should I avoid eating?* The agent recalls the memory.

## Inspect and delete

- The **Memory** tab lists long-term memories (searchable) and stored conversations, each with Delete.
- API: `GET|DELETE /api/projects/{id}/memories[/{memory_id}]` (`?namespace=`, `?q=`) and `GET|DELETE /api/projects/{id}/conversations[/{conversation_id}]`.
- Deleting a project deletes its memory. Expired entries are purged whenever the project's memory is read.

## How recall works

Recall uses BM25-style keyword scoring with light stemming, then fills the remaining `top_k` slots with the most recent memories. Recency fill exists because keyword overlap misses paraphrases ("trip" vs "traveling") and per-user memory sets are small. Recall is not semantic (embedding-based) yet.

## Good practice

- Use a `namespace` per end user so one user's facts never reach another.
- Keep consent explicit and visible. The graph, not the model, decides whether saving is allowed.
- The save tool tells the model never to store secrets, but text is not scanned for secrets before storage; users can delete any entry.

## Theory

See [Memory for AI systems](/learn/memory/) in the handbook for short-term vs long-term memory, summarisation, semantic memory and privacy.
