Skip to content

Intermediate · 30 min

AI Agents & MCP: Give Your Agents Persistent Multimodal Memory

Build AI agents with durable memory and tool calling using Pixeltable. Store conversations, images, and documents as queryable tables, give a Pydantic AI agent read access and a memory table, and call MCP server tools from a computed column.

The Challenge

AI agents lose context between sessions, struggle with multimodal data, and have no durable memory. Building tool-calling agents requires wiring together separate systems for memory, retrieval, and data storage.

The Solution

Pixeltable serves as the persistent memory and data layer for AI agents. Tables store conversations, media, and structured data, and computed columns run embeddings and AI inference on insert. Through pydantic-ai-harness, a Pydantic AI agent gets read-only tools over the tables you allowlist and keeps its notes in a Pixeltable table. Pixeltable is also an MCP client: pxt.mcp_udfs() turns an MCP server's tools into functions an LLM column can call. It has no API that turns your own tables into an MCP server; its own MCP servers are for coding agents.

Implementation Guide

Step-by-step walkthrough with code examples

Step 1 of 5

Agent Memory Table

Create a persistent memory store for agent conversations and context.

python
1import pixeltable as pxt
2from pixeltable.functions.huggingface import sentence_transformer
3
4pxt.create_dir('app', if_exists='ignore')
5
6# Persistent agent memory
7memory = pxt.create_table('app.agent_memory', {
8 'session_id': pxt.String,
9 'role': pxt.String, # 'user', 'assistant', 'tool'
10 'content': pxt.String,
11 'timestamp': pxt.Timestamp,
12 'metadata': pxt.Json,
13}, if_exists='ignore')
14
15# Semantic search over memory; the index updates on every insert
16memory.add_embedding_index(
17 'content',
18 embedding=sentence_transformer.using(
19 model_id='sentence-transformers/all-MiniLM-L6-v2'
20 ),
21 if_exists='ignore',
22)
23
24# Agents can now search their own history
25sim = memory.content.similarity(string='what did we discuss about pricing?')
26relevant = (
27 memory.order_by(sim, asc=False)
28 .select(memory.content, memory.role, memory.session_id)
29 .limit(10)
30 .collect()
31)
Unlike in-memory chat history, this memory persists across sessions and supports semantic retrieval.

Key Benefits

Persistent multimodal memory that survives across sessions
Semantic search over agent history and knowledge bases
Pydantic AI integration: read-only table tools and a memory table through pydantic-ai-harness
MCP client: call any MCP server's tools from a computed column and keep every result
Multimodal tools: agents work with images, video, audio, and documents
Automatic indexing keeps agent knowledge always current

Real Applications

Customer support agents with persistent context
Research assistants with document retrieval
Content creation agents with media search
DevOps agents with log analysis and monitoring
Sales agents with CRM data and document access

Prerequisites

Familiarity with AI agents and LLMs
Basic Python programming
Python 3.11+
pydantic-ai-harness 0.66.0 or later, for the Pydantic AI capability
The mcp package, for pxt.mcp_udfs()
OPENAI_API_KEY for the OpenAI calls; sentence-transformers and transformers for the local MiniLM and CLIP indexes

How-to guides

Ready to get started?

Install Pixeltable and start building in minutes. One Python file for tables, indexes, and HTTP.