Multi-Agent Shared Memory
Category: Architecture
Problem
In multi-agent systems (CrewAI crews, AutoGen teams, custom orchestrators), agents need to share knowledge while maintaining isolation. A research agent's findings should be accessible to a writing agent, but internal reasoning steps should stay private.
Architecture
Use Dakera's namespace system to create a layered memory architecture:
- Private namespaces — each agent writes to its own namespace for internal state
- Shared namespace — agents publish finalized outputs to a common namespace
- Scoped API keys — enforce access control at the API level
Implementation
from dakera import Dakera
# Each agent gets its own client with scoped access
researcher_client = Dakera(
base_url="http://localhost:3300",
api_key="dk-researcher-key" # scoped to: researcher, team-shared (read/write)
)
writer_client = Dakera(
base_url="http://localhost:3300",
api_key="dk-writer-key" # scoped to: writer, team-shared (read/write)
)
# Researcher stores private working notes
researcher_client.memory.store(
content="Found 3 papers on HNSW scaling. Need to verify claims in paper #2.",
namespace="researcher",
metadata={"type": "internal-note", "importance": 0.3}
)
# Researcher publishes verified findings to shared namespace
researcher_client.memory.store(
content="HNSW indexes scale sub-linearly with dataset size. At 10M vectors, query latency is ~5ms with ef=200.",
namespace="team-shared",
metadata={"type": "finding", "source": "researcher", "verified": True}
)
# Writer recalls shared findings
findings = writer_client.memory.recall(
query="HNSW performance characteristics",
namespace="team-shared",
top_k=5
)
# Writer stores its own drafts privately
writer_client.memory.store(
content="Draft intro paragraph uses the HNSW scaling data. Need to simplify for non-technical audience.",
namespace="writer",
metadata={"type": "draft-note"}
)
# Writer publishes final output to shared namespace
writer_client.memory.store(
content="Published article: 'Understanding Vector Search at Scale' — covers HNSW, quantization, and sharding.",
namespace="team-shared",
metadata={"type": "output", "source": "writer", "artifact": "blog-post"}
)
Namespace Architecture
# Create namespaces with isolation
# (via REST API)
curl -X POST http://localhost:3300/v1/namespaces \
-H "Authorization: Bearer dk-admin-key" \
-H "Content-Type: application/json" \
-d '{"name": "team-shared", "description": "Shared knowledge between all agents"}'
curl -X POST http://localhost:3300/v1/namespaces \
-H "Authorization: Bearer dk-admin-key" \
-H "Content-Type: application/json" \
-d '{"name": "researcher", "description": "Private memory for research agent"}'
curl -X POST http://localhost:3300/v1/namespaces \
-H "Authorization: Bearer dk-admin-key" \
-H "Content-Type: application/json" \
-d '{"name": "writer", "description": "Private memory for writing agent"}'
When to Use This Pattern
- CrewAI crews with specialized agents
- AutoGen teams that collaborate on complex tasks
- Pipeline architectures where each stage produces artifacts for the next
- Any system with multiple agents that need coordinated knowledge
Key Considerations
- Only publish verified/finalized data to shared namespaces — internal reasoning creates noise
- Use metadata to track which agent produced each memory (provenance)
- Scoped API keys enforce isolation at the infrastructure level, not just convention
- Consider a "coordinator" namespace for task assignments and status tracking