MemoryMesh — Project Story
Inspiration
AI agents are becoming increasingly capable, but they still have a fundamental limitation: they forget.
An agent may spend time solving a difficult problem, but when another agent encounters a similar problem later, it often has to reason from scratch. This becomes even more problematic when different agents are responsible for different tasks and cannot share what they have learned.
We wanted to solve this by treating memory as a shared infrastructure layer for agents, rather than something owned by one agent.
That idea led to MemoryMesh — a shared, distributed memory layer that allows different AI agents to learn from each other's experiences.
What We Built
MemoryMesh allows one agent to write a useful experience into shared memory and allows another agent to retrieve that experience later using semantic similarity.
For our demonstration:
- Agent A (DevOps) encounters and solves an infrastructure incident.
- Agent A stores the solution in MemoryMesh.
- Agent B (Onboarding) later encounters a differently worded but related problem.
- Instead of solving the problem from scratch, Agent B performs a semantic recall.
- CockroachDB's vector indexing finds the relevant memory.
- Agent B reuses the previous solution and avoids unnecessary reasoning.
The important part is that Agent B was not designed to communicate directly with Agent A. They communicate through the shared memory layer.
MemoryMesh also records recalls in a memory_recalls audit table, allowing us to demonstrate that the memory was actually reused and measure the resulting time savings.
How It Works
The core architecture uses CockroachDB as the shared memory layer.
Each memory contains structured information along with an embedding stored in a VECTOR column. CockroachDB's vector index enables semantic retrieval using the <-> distance operator.
This means the system does not depend on exact keyword matching. Two agents can describe essentially the same problem using completely different language and still retrieve the relevant memory.
The architecture is:
Agent A ── remember() ──┐
│
▼
┌──────────────┐
│ CockroachDB │
│ Shared Memory│
│ │
│ Vector Index │
│ Recall Audit │
└──────┬───────┘
│
│ recall()
▼
Agent B
The application is exposed through a FastAPI service and can be deployed serverlessly using AWS Lambda.
We also integrated the architecture with Amazon Bedrock as an optional embedding provider for real semantic embeddings.
During development, we used the CockroachDB Cloud Managed MCP Server to inspect the memory tables and recall history directly from our development environment.
Why This Is More Than a Database
MemoryMesh is not simply storing records in a database.
The key concept is cross-agent learning.
A memory is created by one agent because it solved a problem. Later, another independent agent can discover and reuse that knowledge when it encounters a related situation.
This creates a simple but powerful loop:
$$ Experience \rightarrow Memory \rightarrow Retrieval \rightarrow Reuse $$
The memory_recalls audit log provides evidence of that reuse instead of treating memory as an invisible abstraction.
What We Learned
Building MemoryMesh taught us that reliable agent memory requires more than simply storing text.
We learned how to:
- Use CockroachDB's distributed vector indexing for semantic retrieval.
- Design a shared memory schema for multiple agents.
- Connect AI-agent workflows to a persistent database.
- Build a FastAPI service around the memory layer.
- Package an application for AWS Lambda using Mangum.
- Explore Amazon Bedrock embeddings.
- Use CockroachDB's MCP Server during development.
- Track memory reuse through an audit log.
- Think about memory retrieval as a measurable part of an agentic system.
One particularly important lesson came from debugging semantic similarity.
CockroachDB's <-> operator returns L2 distance. Because our embeddings are normalized, converting that distance into similarity requires:
$$ similarity = 1 - \frac{distance^2}{2} $$
Using the wrong conversion caused relevant memories to appear less similar than they actually were. Fixing this made the semantic recall behavior much more reliable.
Challenges
One of the biggest challenges was making sure Agent B could actually retrieve Agent A's memory when the two agents used different wording.
A simple keyword search would fail for many realistic cases. We therefore designed the memory layer around vector embeddings and semantic similarity.
Another challenge was making the system useful without requiring expensive infrastructure during development. We addressed this by providing a local embedding fallback while keeping Amazon Bedrock available for production-style semantic embeddings.
We also had to think carefully about deployment. The application needed to work as a normal FastAPI service during development while also being deployable as a serverless AWS Lambda application. Mangum provided the bridge between FastAPI and Lambda.
Finally, we wanted to make memory reuse observable rather than simply claiming that it happened. The memory_recalls table provides an audit trail showing when one agent retrieves knowledge created by another.
What's Next
MemoryMesh is designed as a foundation that can be extended beyond our current two-agent demonstration.
Future versions could support:
- Memory expiration and automatic cleanup.
- Memory confidence scores.
- Conflict detection when agents learn contradictory information.
- Memory ownership and access policies.
- Feedback-driven memory quality scoring.
- More sophisticated long-term agent memory.
- Multiple agent types sharing the same knowledge layer.
- Production-scale deployment across distributed agent systems.
Our goal is to make agent memory feel less like a temporary conversation history and more like shared infrastructure that agents can continuously learn from.
Final Takeaway
The central idea behind MemoryMesh is simple:
An agent should not have to solve a problem twice if another agent has already solved it.
By combining CockroachDB's distributed vector capabilities, persistent shared memory, cross-agent retrieval, auditability, and AWS serverless deployment, MemoryMesh demonstrates how independent AI agents can learn from each other's experiences without needing to communicate directly.
Built With
- agentic
- agents
- ai
- amazon
- amazon-web-services
- bedrock
- cockroachdb
- embeddings
- fastapi
- lambda
- mcp
- python
- search
- semantic
- vector
Log in or sign up for Devpost to join the conversation.