---
title: "Build an agent with memory"
description: "Create an AI agent that remembers important information across conversations."
url: "https://www.pixeltable.com/notebooks/pattern-agent-memory"
updated: "2026-04-10"
---

# Build an agent with memory

Create an AI agent that remembers important information across conversations.

- **Type:** Notebook
- **Group:** Agents

## How it works

This pattern is inspired by Pixelbot and Pixelmemory.

## What it covers

- Store memories with embeddings for semantic search
- Retrieve relevant memories based on conversation context
- Use @pxt.query for retrieval functions

## What it uses

- **Install:** `pip install pixeltable openai`
- **Environment variables it names:** `OPENAI_API_KEY`
- **Pixeltable calls:** `openai.chat_completions()`, `pxt.create_table()`, `@pxt.query`, `@pxt.udf`, `add_embedding_index()`, `similarity()`, `insert()`, `add_computed_column()`

## A look at the code

```python
# Add embedding index for semantic search on content
memories.add_embedding_index(
    column='content',
    string_embed=embeddings.using(model='text-embedding-3-small'),
)
```

## Open it

- **Open in Colab:** https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/agents/pattern-agent-memory.ipynb
- **Docs page:** https://docs.pixeltable.com/howto/cookbooks/agents/pattern-agent-memory
- **Source on GitHub:** https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/agents/pattern-agent-memory.ipynb
