---
title: "Memory — Context Infrastructure"
description: "Context that belongs to a session."
canonical: "https://press.getalchemystai.com/books/context-infrastructure-build-ai-that-understands-your-business/memory"
last_updated: "2018-10-20"
book: "Context Infrastructure"
label: "Chapter 9"
---

# Memory

Memory is context that belongs to a session: what a user said, what an agent promised, what is still open. It lives in the same knowledge graph as your documents, so an agent can combine "what this customer told us last week" with "what our refund policy says" in one retrieval.

```ts
await client.v1.context.memory.add({
  sessionId: 'ticket-1234',
  contents: [
    { content: 'Customer reports login fails with "invalid credentials".', role: 'user' },
    { content: 'Sent a password reset link; customer confirmed it worked.', role: 'assistant' },
  ],
  metadata: { groupName: ['support', 'tickets'] },
});
```

Use `memory.update` to revise entries in a session and `memory.delete` to remove one. The same tools are exposed over MCP (`alchemyst_ai_memory_add`, `_update`, `_delete`, `_search`), so an IDE assistant can save and recall memory without custom code.

## User profiling

Consumer AI applications fail when every user is treated the same. Memory lets an application build a living profile from what users actually do.

| User signal | What memory captures | What the user experiences |
| --- | --- | --- |
| Past questions | Topics of interest, knowledge gaps | Explanations pitched at the right level |
| Response feedback | Preferred length and format | Answers that match their style |
| Repeated behaviours | Workflow patterns, common tasks | Proactive shortcuts |
| Explicit preferences | Likes, dislikes, constraints | Filtered recommendations |
| Temporal patterns | Active hours, frequency | Well-timed engagement |

Scope profiles per user with `groupName` or namespaces, never store what the user would not expect you to keep, and give users a way to see and delete it.

---

- Previous: [Chapter 8: Keep It Current](https://press.getalchemystai.com/books/context-infrastructure-build-ai-that-understands-your-business/keep-it-current.md)
- Contents: [Context Infrastructure](https://press.getalchemystai.com/books/context-infrastructure-build-ai-that-understands-your-business.md)
- Next: [Chapter 10: Ask and Steer](https://press.getalchemystai.com/books/context-infrastructure-build-ai-that-understands-your-business/ask-and-steer.md)
