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

Agent memory: a turn recalls rows, then may write a new one1. Event: User message (or tool result). 2. Recall: @pxt.query (similarity + filter). 3. Memory bank: Memory rows (content, category, time), Embedding index (or Qdrant / Mem0). 4. Generate: Prompt + LLM (memories in context). 5. Write-back: Insert a fact (optional extract)1. EventUser messageor tool result2. Recall@pxt.querysimilarity + filter3. Memory bankMemory rowscontent, category, timeEmbedding indexor Qdrant / Mem04. GeneratePrompt + LLMmemories in context5. Write-backInsert a factoptional extract

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.

Named alternatives for Agent memory backend reference architecture
SlotRolePixeltableNamed alternatives
Memory productOpinionated extract, recall, and forgetTables, an EmbeddingIndex, and @pxt.query; you write extract and forget
  • Mem0. You want a hosted or embeddable memory layer with their extract/forget policy
  • Letta (MemGPT). You want their agent runtime and hierarchical memory, not only a table
  • Zep. You want a temporal knowledge graph as the memory product
Vector indexSemantic recallEmbeddingIndex on the content column
  • Qdrant. Collections, payload filters, and an ANN SLA you already run
  • pgvector. Postgres already holds user data and you want SQL next to vectors
  • Pinecone. A hosted ANN namespace per tenant is the contract
Embedding modelVectors for content and for the current turnopenai.embeddings or sentence_transformer as string_embed
  • OpenAI text-embedding-3-small. A hosted embedding API; used in the docs cookbook
  • sentence-transformers. Local embeddings with no API key
Agent runtimeThe loop that calls recall and toolsComputed columns on a conversations table, or a @pxt.query tool
  • LangGraph. The loop is already LangGraph; Pixeltable is the store the tools hit
  • Pixelagent. You want Pixeltable examples of planning and tools

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 pxt
from pixeltable.functions.openai import chat_completions, embeddings
TableModel = pxt.model_base()
text_embed = embeddings.using(model='text-embedding-3-small')
class Memories(TableModel, name='memories'):
content: pxt.String
category: pxt.String
created_at: pxt.Timestamp
__indexes__ = [
pxt.EmbeddingIndex(content, string_embed=text_embed),
]
@pxt.query
def 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.udf
def 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.String
relevant_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.

Questions

How is this different from Mem0, Letta, or Zep?

Those products package extract, recall, and (in some cases) forget. Pixeltable is the table, the index, and the query. Use their product when that policy is what you want to buy. Use this schema when the rows, the model, and HTTP should live in a file you own.

Does Pixeltable decide what to forget?

No. Forgetting is a rule you write: delete by category, by age, or by a score you compute. This page does not invent a forget policy.

Can LangGraph call this store?

Yes. Expose recall_memories as a tool. LangGraph runs the loop. Pixeltable vs LangChain is the data plane versus the loop.