Multi-Agent Memory
Use separate Mnemosyne instances to coordinate memory across a team of agents.
Mnemosyne's multi-agent sharing works via the same SQLite database file on the same filesystem. For cross-machine sharing, use the MCP SSE server (mnemosyne mcp --transport sse --port 8080) or manual export/import.
Architecture
graph TB
subgraph Team["Agent Team"]
A1[Agent A]
A2[Agent B]
A3[Agent C]
end
subgraph Storage["Storage"]
DBA[(Agent A DB)]
DBB[(Agent B DB)]
DBC[(Agent C DB)]
DBS[(Shared DB)]
end
A1 -->|private| DBA
A2 -->|private| DBB
A3 -->|private| DBC
A1 -->|shared| DBS
A2 -->|shared| DBS
A3 -->|shared| DBS
Separate Database Instances
Each agent gets its own Mnemosyne instance. Use separate db_path values for isolation, or share a path for coordination:
from mnemosyne import Mnemosyne
# Each agent has its own isolated database
agent_a = Mnemosyne(
session_id="agent-a",
db_path="/data/agent-a/memories.db",
)
agent_b = Mnemosyne(
session_id="agent-b",
db_path="/data/agent-b/memories.db",
)
# Agent A stores an observation
agent_a.remember(
content="The API rate limit is 1000 req/min.",
source="observation",
importance=0.9,
)
# Agent B cannot see Agent A's memories
results = agent_b.recall("API rate limit") # Returns nothing from agent-a's DB
Shared Memory with Identity (since v2.3)
Every agent gets its own author_id and shares a channel_id. Memories are auto-tagged with who stored them:
from mnemosyne import Mnemosyne
# Agent A: Abdias (human user)
abdias = Mnemosyne(
session_id="abdias-session",
author_id="abdias",
author_type="human",
channel_id="fluxspeak-team",
)
# Agent B: Codex (AI agent)
codex = Mnemosyne(
session_id="codex-session",
author_id="codex",
author_type="agent",
channel_id="fluxspeak-team",
)
# Abdias stores a preference
abdias.remember("Dark mode is preferred", importance=0.9)
# Codex stores a deploy result
codex.remember("Deploy succeeded at 3PM", importance=0.8)
Recalling in a Channel
With channel_id, agents in different sessions see each other's memories:
# Abdias asks: what happened in the team channel?
results = abdias.recall("deploy", channel_id="fluxspeak-team")
# Returns Codex's deploy memory!
# Codex asks: any user preferences?
results = codex.recall("dark", channel_id="fluxspeak-team")
# Returns Abdias's preference!
Filtering by Author
Need to know who said what? Filter by author_id or author_type:
# What did Abdias specifically store?
results = abdias.recall("preference", author_id="abdias")
# What did all agents (not humans) store?
results = abdias.recall("deploy", author_type="agent")
# How many memories does Abdias have?
stats = abdias.get_stats(author_id="abdias")
# How many in the whole channel?
stats = abdias.get_stats(channel_id="fluxspeak-team")
Cross-Machine Sharing via MCP
Run the MCP SSE server on one machine and connect agents from any machine on the network:
# Machine A: Start the MCP server
mnemosyne mcp --transport sse --port 8080 --bank team
# Machine B: Connect an agent with identity
MNEMOSYNE_AUTHOR_ID=agent-b \
MNEMOSYNE_AUTHOR_TYPE=agent \
MNEMOSYNE_CHANNEL_ID=team \
your-mcp-client --url http://machine-a:8080/sse
Any MCP-compatible client (Claude Desktop, Goose, Cursor, etc.) can connect. Memories are shared across the network through the server.
For offline or batch transfer, use export/import:
# On machine A: export shared memories
agent_a.export_to_file("/shared/team-memory-export.json")
# On machine B: import
agent_b.import_from_file("/shared/team-memory-export.json")
Deployment
Use a shared volume or network filesystem:
- Docker: Named volume mounted to all agents
- Kubernetes: Shared PVC
- Fly.io: Same volume mounted to multiple machines
SQLite handles multiple readers well but prefers single-writer. For high-write multi-agent scenarios, consider WAL mode or connection pooling.
Mnemosyne