Sharing Memory Between Multiple AI Agents
Free · Open source (MIT) · Works with LangChain, CrewAI, AutoGen · No signup
When you're building a multi-agent system — whether it's a research team, trading bot cluster, or content generation pipeline — your agents need to share state. One agent discovers something, another needs to act on it. Without shared memory, you're building isolated bots that can't coordinate. Here's how to implement persistent multi agent memory that survives restarts and works across processes.
The Problem with Agent Coordination Memory
AI agents are stateless by default. Each conversation starts fresh, and when the process dies, everything vanishes. This breaks multi-agent patterns where coordination is critical.
Picture a trading system: Agent A analyzes market sentiment and flags "TSLA showing unusual volume." Agent B handles risk management and needs that context to adjust position sizing. Agent C executes trades and should know about both the signal and the risk adjustment. Without shared agent state, Agent B never sees A's discovery, and Agent C trades blind.
The same pain hits research teams. One agent scrapes competitor pricing, another analyzes the data, a third generates reports. If they can't share findings, each agent reinvents the wheel or makes decisions with stale information.
Session-based memory doesn't help here — you need persistent, cross-agent, cross-process memory that multiple agents can read and write simultaneously.
The Fix: Persistent Multi-Agent State
Install BotWire Memory for shared state that persists across agents, processes, and machine restarts:
pip install botwire
Here's the basic pattern — multiple agents sharing a common memory namespace:
from botwire import Memory
# Agent A: Market Analysis
market_memory = Memory("trading-desk")
market_memory.set("tsla_signal", {
"symbol": "TSLA",
"signal": "unusual_volume",
"confidence": 0.85,
"timestamp": "2024-01-15T10:30:00Z"
})
# Agent B: Risk Management (different process/machine)
risk_memory = Memory("trading-desk") # same namespace
signal = risk_memory.get("tsla_signal")
if signal and signal["confidence"] > 0.8:
risk_memory.set("tsla_position_limit", {"max_shares": 500, "reason": "high_confidence_signal"})
# Agent C: Trade Execution
execution_memory = Memory("trading-desk")
signal = execution_memory.get("tsla_signal")
limit = execution_memory.get("tsla_position_limit")
# Now Agent C has context from both A and B
How Multi-Agent Memory Works
The Memory("namespace") creates a shared memory pool. All agents using the same namespace can read/write the same keys. Data persists in BotWire's backend, so agents can restart, crash, or run on different machines — the memory survives.
For research teams, this enables handoff patterns:
from botwire import Memory
# Research Agent 1: Data Collection
research_memory = Memory("research-team")
research_memory.set("competitor_pricing", {
"shopify": {"basic": 29, "pro": 79},
"woocommerce": {"basic": 0, "extensions": 200},
"scraped_at": "2024-01-15T14:00:00Z"
})
research_memory.set("status", "data_collection_complete")
# Research Agent 2: Analysis (waits for data)
analysis_memory = Memory("research-team")
while analysis_memory.get("status") != "data_collection_complete":
time.sleep(5)
pricing_data = analysis_memory.get("competitor_pricing")
analysis = {"avg_basic_price": 14.5, "recommendation": "price_below_average"}
analysis_memory.set("pricing_analysis", analysis)
analysis_memory.set("status", "analysis_complete")
You can list all keys to see what's been shared: research_memory.list_keys() returns all keys in the namespace. To clean up: research_memory.delete("old_key") removes specific entries.
This works across processes because BotWire Memory is HTTP-based, not in-process storage. Agent A runs in Docker, Agent B on your laptop, Agent C in production — all share the same memory pool.
Framework Integration
For CrewAI users, BotWire provides ready-made memory tools:
from crewai import Agent, Task, Crew
from botwire.memory import memory_tools
# Give all agents access to shared memory tools
shared_tools = memory_tools("crew-research")
researcher = Agent(
role="Data Collector",
goal="Gather competitor data",
tools=shared_tools,
# Agent can now use remember(), recall(), and list_memory() tools
)
analyst = Agent(
role="Data Analyst",
goal="Analyze collected data",
tools=shared_tools, # Same memory namespace
)
crew = Crew(agents=[researcher, analyst])
The memory_tools() function returns three tools: remember(key, value) to store data, recall(key) to retrieve it, and list_memory() to see all stored keys. All agents in the crew can coordinate through shared memory.
When NOT to Use BotWire
- Vector search: BotWire is key-value storage, not a vector database. For semantic similarity or embedding search, use Pinecone or Chroma.
- High-throughput trading: The HTTP API adds latency. For microsecond-sensitive applications, use Redis or in-memory solutions.
- Large file storage: 50MB namespace limit. For images, documents, or datasets, use S3 or dedicated file storage.
FAQ
Why not just use Redis? Redis requires setup, authentication, and infrastructure management. BotWire works immediately with no configuration — just pip install and go.
Is this actually free? Yes. 1000 writes/day per namespace, unlimited reads, no credit card required. The free tier is permanent, not a trial.
What about data privacy? Your data stays in your namespace, isolated from others. For sensitive applications, self-host the open-source version (it's a single FastAPI service).
Get Started
Multi-agent coordination becomes trivial when agents can share persistent memory. Install BotWire and start building agent teams that actually coordinate: pip install botwire. Full docs and self-hosting instructions at https://botwire.dev.