A complete three-layer memory system for OpenClaw multi-agent setups.
┌─────────────────────────────────────────────────────┐
│ Agent Memory │
│ │
│ Layer 1: Private Files (QMD) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ piper/ │ │ paige/ │ │ dean/ │ ... │
│ │ memory/ │ │ memory/ │ │ memory/ │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ Per-agent vector search via memory_search │
│ │
│ Layer 2: Shared Files (_shared/) │
│ ┌──────────────────────────────────┐ │
│ │ user-profile.md │ │
│ │ agent-roster.md │ │
│ │ infrastructure.md │ │
│ │ graphiti-memory.md │ │
│ └──────────────────────────────────┘ │
│ Symlinked into each agent workspace as shared/ │
│ Indexed by QMD alongside private files │
│ │
│ Layer 3: Shared Knowledge Graph (Graphiti) │
│ ┌──────────────────────────────────┐ │
│ │ clawdbot-clawd (write own) │ │
│ │ clawdbot-piper (write own) │ │
│ │ user-main (orchestrator) │ │
│ │ system-shared (orchestrator) │ │
│ └──────────────────────────────────┘ │
│ Cross-group search for temporal facts │
└─────────────────────────────────────────────────────┘
| Layer | What | Best For | Mutability |
|---|---|---|---|
| Private Files | Agent's own memory/ dir |
Private notes, task logs, local state | Agent writes freely |
| Shared Files | _shared/ dir (symlinked) |
Stable reference docs (profiles, roster) | Orchestrator maintains |
| Shared Graph | Graphiti knowledge graph | Temporal facts, cross-agent knowledge | Agents write to own group |
- "What's the user's email?" → Shared files (
user-profile.md) or Graphiti - "What did I log yesterday?" → Private files (
memory_search) - "What did Piper find about that invoice?" → Graphiti (cross-group search)
- "Who handles security?" → Shared files (
agent-roster.md) - "When did we change the deployment config?" → Graphiti (temporal)
- OpenClaw installed and configured
- Docker (for Graphiti + Neo4j)
- An OpenAI API key (for Graphiti embeddings)
git clone https://github.com/your-username/openclaw-graphiti-memory.git
cd openclaw-graphiti-memory
# Copy docker-compose to your services directory
cp docker-compose.yml ~/clawd/services/graphiti/
# Set your OpenAI key
export OPENAI_API_KEY="sk-..."
# Start the stack
cd ~/clawd/services/graphiti
docker compose up -dAdd to ~/.openclaw/openclaw.json under agents.defaults:
{
"memorySearch": {
"enabled": true,
"sources": ["memory", "sessions"],
"provider": "gemini",
"model": "gemini-embedding-001",
"sync": {
"onSessionStart": true,
"watch": true
}
}
}# Create the shared directory
mkdir -p ~/clawd/agents/_shared/bin
# Copy shared scripts
cp scripts/graphiti-search.sh ~/clawd/agents/_shared/bin/
cp scripts/graphiti-log.sh ~/clawd/agents/_shared/bin/
cp scripts/graphiti-context.sh ~/clawd/agents/_shared/bin/
chmod +x ~/clawd/agents/_shared/bin/*.sh
# Copy shared reference files
cp shared-files/*.md ~/clawd/agents/_shared/
# Symlink into each agent's workspace
for agent_dir in ~/clawd/agents/*/; do
agent=$(basename "$agent_dir")
[[ "$agent" == "_shared" || "$agent" == "_template" ]] && continue
ln -sf ~/clawd/agents/_shared "$agent_dir/shared"
doneAdd the shared memory section to each agent's AGENTS.md. See templates/shared-memory-snippet.md for a copy-paste template, or use the patch script:
python3 scripts/patch-shared-memory.py# Seed user profile
scripts/graphiti-log.sh user-main system "System" "User lives in Example City, EST timezone."
# Seed agent roster
scripts/graphiti-log.sh system-shared system "System" "Agent team: Clawd (orchestrator), Piper (email), Paige (finance)..."| Script | Purpose |
|---|---|
graphiti-search.sh "query" [group_id] [max] |
Search knowledge graph |
graphiti-log.sh <agent_id> <role> <name> "content" |
Log facts to own group |
graphiti-context.sh "task" [agent_id] |
Get full context for a task |
| Script | Purpose |
|---|---|
memory-hybrid-search.sh "query" |
Search QMD + Graphiti together |
graphiti-import-files.py |
Bulk import files into Graphiti |
graphiti-sync-sessions.py |
Sync session transcripts to Graphiti |
graphiti-watch-files.py |
Watch files and auto-sync to Graphiti |
patch-shared-memory.py |
Patch all agent AGENTS.md files |
| Group | Owner | Purpose |
|---|---|---|
clawdbot-<agent_id> |
Each agent | Agent's own discoveries and decisions |
user-main |
Orchestrator | User profile, preferences, contacts |
system-shared |
Orchestrator | Agent roster, infrastructure, active projects |
- Agents write to their own group only
- Agents read cross-group (omit
group_idfor global search) - Only the orchestrator writes to
user-mainandsystem-shared - Shared files in
_shared/are read-only for agents — report updates to orchestrator
The included docker-compose.yml runs:
- Graphiti API (port 8001) — REST API for the knowledge graph
- Neo4j (ports 7474/7687) — Graph database backend
Environment variables:
OPENAI_API_KEY— Required for embeddingsMODEL_NAME— LLM for entity extraction (default:gpt-4.1-mini, recommendgpt-4.1)
- QMD: Free (local, uses Gemini embeddings which are free tier)
- Graphiti: OpenAI API costs for entity extraction during ingestion only
gpt-4.1: ~$2/M input, $8/M output tokens- Searches are free (local Neo4j queries)
- Typical cost: < $1/month for a 20-agent setup
MIT