🔮
Pydantic AI+Stompy

Type-safe agents that actually remember their training

Because your agents deserve better than amnesia

The Problem

You've built a beautiful type-safe agent with Pydantic AI. It validates inputs. It structures outputs. It's a masterpiece of modern Python engineering.

And then you close your terminal.

The next morning, your agent greets you like a stranger at a party. "Hi! I'm an AI assistant. How can I help you today?" As if you didn't spend three hours yesterday explaining your entire codebase architecture.

Every. Single. Session.

Your agent has the memory of a goldfish with a PhD. Technically brilliant, but unable to remember anything past the last context window. You've become that person who repeats the same story at every dinner party—except the dinner party is your IDE, and the story is "this is how our authentication works."

How Stompy Helps

Stompy gives your Pydantic AI agents an external brain that persists between sessions.

When you save context, Stompy: - Embeds it into high-dimensional vectors for semantic search - Evaluates novelty to prevent redundant storage (delta evaluation) - Versions content so you can track how knowledge evolved - Generates automatic session handovers summarizing what happened

Your agent remembers: - Project architecture decisions ("We're using PostgreSQL, not MongoDB") - Code conventions ("We prefer explicit over implicit") - Domain knowledge ("Users can have multiple workspaces") - Previous debugging sessions ("The auth bug was in the token refresh")

At session start, your agent gets a handover summary of the previous session. Semantic search finds relevant context even when you don't remember the exact topic name—because it's searching meaning, not just keywords.

Your agent on Stompy doesn't just respond—it understands where you left off.

Integration Walkthrough

1

Connect Stompy via SSE with bearer auth

Pydantic AI supports SSE MCP transport. Connect to Stompy with your token.

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerHTTP
import os
# Connect to Stompy via SSE
stompy = MCPServerHTTP(
url="https://mcp.stompy.ai/sse",
headers={"Authorization": f"Bearer {os.environ['STOMPY_TOKEN']}"}
)
agent = Agent(
'claude-3-5-sonnet-latest',
mcp_servers=[stompy],
system_prompt="Use lock_context/recall_context/context_search for memory."
)
2

Agent saves knowledge with lock_context

When your agent learns something important, it uses lock_context to save it. Topic names are stable — content is versioned.

async with agent:
result = await agent.run(
"Add JWT auth to the /users endpoint"
)
# Agent saves detailed context:
# → lock_context(
# topic="auth_patterns",
# content="""Authentication Implementation:
# - Library: python-jose with RS256 algorithm
# - Token location: Authorization header (Bearer scheme)
# - Expiry: 15 minutes for access, 7 days for refresh
# - Claims: sub (user_id), exp, iat, scope
# - Middleware: src/middleware/auth.py
# - NEVER store tokens in localStorage (XSS risk)
# - ALWAYS validate token signature before trusting claims""",
# priority="always_check",
# tags="security,auth,jwt"
# )
# → Creates v1.0, embeds to vectors for semantic search
3

Agent recalls by topic name

In future sessions, your agent checks for existing context first. Same topic name, always gets the latest version.

# Session 47: Agent checks memory first
result = await agent.run(
"Add authentication to the /payments endpoint"
)
# Agent calls recall_context("auth_patterns") → gets v1.0
# Then applies your patterns consistently:
# "Adding JWT auth to /payments using python-jose with RS256,
# same pattern as /users..."
4

Semantic search finds related context

context_search uses embeddings to find relevant knowledge even when you don't know the exact topic name.

# Agent needs something about security but doesn't know topic
result = await agent.run(
"Review security for the checkout flow"
)
# Agent uses semantic search:
# → context_search("security authentication checkout")
# Returns: auth_patterns (0.89), api_security (0.76), ...
# Agent combines relevant contexts automatically
5

Delta evaluation prevents redundancy

Stompy evaluates new content for novelty. Redundant saves are rejected, keeping your knowledge base clean.

# Agent tries to save something already known
# → lock_context(topic="auth_patterns",
# content="We use JWT with RS256...")
# Stompy: "Content is 92% redundant with existing context.
# Use force_store=True to override."
# Only genuinely new knowledge gets stored

What You Get

  • Automatic session handovers—start each session with a summary of the last
  • Semantic search (vector embeddings) finds context by meaning, not keywords
  • Delta evaluation rejects redundant content automatically
  • Priority system (always_check/important/reference) surfaces critical rules
  • Conflict detection catches contradictory information before it causes bugs

Ready to give Pydantic AI a memory?

Join the waitlist and be the first to know when Stompy is ready. Your Pydantic AI projects will never forget again.