Reference architecture
Agent memory backend reference architecture
Agent memory is a store of facts and preferences the model did not see in the current messages. Embed the rows, recall the ones similar to this turn, and put them in the prompt. Mem0, Letta, and Zep are products for that job. Pixeltable is the table you write instead.
Updated · Matching docs cookbook
Short-term context is the messages in this call. Long-term memory is rows that outlive the call: preferences, facts, episode summaries. The architecture is a bank, an index, a recall query, a prompt, and an optional write-back. Forgetting is a product rule (age, category, a score). This page does not invent a forget algorithm.
The interactive agent diagram on this site is /ai-agent-architecture. The docs cookbook is Build an agent with memory (notebook API). The sketch below is the same shape as a TableModel in app.py. The runnable gallery app is Research Agent Memory on /recipes.
Agent memory: a turn recalls rows, then may write a new one
Role of each component
- Memory bank
- Rows with content, an optional category, and a timestamp. A vector with no source string cannot be cited or deleted on purpose.
- Embedding index
- Nearest-neighbor search over content. The same model at insert and at recall. A hosted memory product hides this index.
- Recall query
- Rank by similarity, optionally filter by category or time, return top_k. The docs cookbook also uses a similarity threshold (sim > 0.5).
- Prompt builder
- A UDF that joins recalled rows into the system or user prompt. The model never queries the bank itself unless you expose recall as a tool.
- Write-back
- Insert a new fact after the turn, or let a tool do it. Extraction quality is a model problem, not an index problem.
- Agent loop
- LangGraph, a custom loop, or Pixelagent. The loop is not the store. Pixeltable vs LangChain is that split.
Honest alternatives per slot
Keep the named engine when it is already the contract. Pixeltable fills the slot when you want that job on the same table as the files.
| Slot | Role | Pixeltable | Named alternatives |
|---|---|---|---|
| Memory product | Opinionated extract, recall, and forget | Tables, an EmbeddingIndex, and @pxt.query; you write extract and forget |
|
| Vector index | Semantic recall | EmbeddingIndex on the content column |
|
| Embedding model | Vectors for content and for the current turn | openai.embeddings or sentence_transformer as string_embed |
|
| Agent runtime | The loop that calls recall and tools | Computed columns on a conversations table, or a @pxt.query tool |
|
Where Pixeltable fits
Pixeltable is the memory backend in this architecture: a memories table, an EmbeddingIndex, recall as @pxt.query, and a conversations table whose computed columns retrieve then generate. Keep Mem0, Letta, or Zep when their extract/forget policy is the product. Keep Qdrant or pgvector when that engine is already the index. The interactive diagram at /ai-agent-architecture is the broader agent system; this page is the store. Pixeltable Cloud hosts the same app file.
import pixeltable as pxtfrom pixeltable.functions.openai import chat_completions, embeddingsTableModel = pxt.model_base()text_embed = embeddings.using(model='text-embedding-3-small')class Memories(TableModel, name='memories'):content: pxt.Stringcategory: pxt.Stringcreated_at: pxt.Timestamp__indexes__ = [pxt.EmbeddingIndex(content, string_embed=text_embed),]@pxt.querydef recall_memories(context: str, top_k: int = 3):sim = Memories.content.similarity(string=context)return (Memories.where(sim > 0.5).order_by(sim, asc=False).limit(top_k).select(content=Memories.content, category=Memories.category))@pxt.udfdef build_memory_prompt(user_message: str, relevant_memories: list[dict]) -> str:memory_text = '\n'.join(f"- {row['content']}" for row in relevant_memories)return ('You are a helpful assistant with access to the following memories:\n\n'f'{memory_text}\n\n''Use these memories to personalize your response when relevant.\n\n'f'User: {user_message}')class Conversations(TableModel, name='conversations'):user_message: pxt.Stringrelevant_memories = recall_memories(user_message, top_k=3)prompt = build_memory_prompt(user_message, relevant_memories)response = chat_completions(messages=[{'role': 'user', 'content': prompt}],model='gpt-4o-mini',)assistant_reply = response.choices[0].message.content# pxt init# pxt schema update app.py agent_memory -f# Insert facts into memories; insert turns into conversations.
To run a sketch, install pixeltable[serve] and the packages its model functions import (such as sentence-transformers, openai, or openai-whisper), export the provider key a model call reads (such as OPENAI_API_KEY), save the file as app.py, and run the commands in its last lines. The tables start empty: insert a row, or POST to an insert route, then select the computed columns. Get started covers the CLI.