MemClawz is a private memory API for AI agents. It provides fast semantic search, composite-scored retrieval, background enrichment, and automated compaction over a Qdrant vector store.
Designed for the OpenClaw ecosystem. Internal use only.
- Write-only access tier for external fleet members (two-tier auth proxy)
- Rate limiting on auth proxy (5 failed attempts → 5-min block)
- Security hardening: token rotation, IP allowlist management
- Fleet sync compatibility:
memclawz-synccron module works with write-only tokens
v11 is a ground-up strip to core essentials. 15,900+ lines removed, zero functionality loss for production workloads.
- 3.8× faster throughput end-to-end vs v10
- Dramatically better search quality — cleaner scoring, less noise
- Leaner memory footprint and faster cold starts
v11 keeps only what matters:
| Module | Purpose |
|---|---|
api.py |
FastAPI endpoints: search, add, memories, stats, compaction |
config.py |
Environment-based configuration |
scoring.py |
Composite scoring: semantic similarity + recency + type weight + frequency |
enrichment.py |
Async Gemini-powered memory enrichment |
compactor.py |
3-tier compaction: session → daily → weekly |
qdrant_store.py |
Qdrant operations, counters, dedup |
classifier.py |
Memory type classification |
utils.py |
Shared utilities |
routing.py |
Lightweight routing helpers (retained) |
compaction_cron.py |
Background compaction scheduler |
The following modules were deleted — they added complexity without production value:
federation.py— cross-node memory exchangefleet_sync.py— routing tables, delegation, fleet coordinationgraphiti_layer.py— Neo4j/Graphiti temporal graphhybrid_search.py— multi-backend search fusionrouting_audit.py— routing telemetry reportsrouting_crystallize.py— routing-aware crystallizationreflection.py— sleep-time reflectionself_links.py— self-referential memory linkstemplate_distributor.py— agent template distributionv7_extensions.py— legacy v7 compatibilitylifecycle.py— 8-state memory lifecyclenightcron/— nightly automation jobsmcp_server.py— MCP serverpipelines.py— pipeline orchestrationrouter.py— advanced routing enginecontradiction.py,decay.py,importer.py,watcher.pytemplates/— orchestrator and specialist bundles (15 agents)reports/— routing audit reports
| Method | Path | Purpose |
|---|---|---|
| GET | /health |
Health + dependency status |
| GET | /api/v1/search |
Semantic search with composite scoring |
| POST | /api/v1/add |
Write with async enrichment |
| POST | /api/v1/add-direct |
Direct write (no enrichment) |
| GET | /api/v1/memories |
List/filter memories |
| GET | /api/v1/agents |
Per-agent memory counts |
| GET | /api/v1/stats |
Aggregate stats (cached) |
| DELETE | /api/v1/memory/{id} |
Delete a memory |
| PUT | /api/v1/memory/{id} |
Update a memory |
| POST | /api/v1/compact/session |
Session compaction |
| POST | /api/v1/compact/daily |
Daily digest compaction |
| POST | /api/v1/compact/weekly |
Weekly merge compaction |
| GET | /api/v1/compact/status |
Compaction status |
curl -s -G http://127.0.0.1:3500/api/v1/search \
--data-urlencode 'q=deploy issue' \
--data-urlencode 'limit=5' | jqcurl -s -X POST http://127.0.0.1:3500/api/v1/add \
-H 'Content-Type: application/json' \
-d '{
"content": "The v11 migration completed successfully.",
"user_id": "admin",
"agent_id": "main",
"memory_type": "fact"
}' | jqRetrieval combines four signals:
- Semantic similarity — vector cosine distance
- Recency decay — newer memories score higher
- Type-based importance —
decision,preference,commitmentresist decay - Access frequency — frequently-retrieved memories get boosted
| Tier | Trigger | Effect |
|---|---|---|
| Session | End of agent session | Summarize session into durable outputs |
| Daily | Daily schedule | Digest recent operational memory |
| Weekly | Weekly schedule | Merge repeated patterns, reduce duplication |
cd ~/memclawz
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
# Configure
cp .env.example .env # edit with your Qdrant host, API keys, etc.
# Run
python -m uvicorn memclawz.api:app --host 127.0.0.1 --port 3500
# Health check
curl -s http://127.0.0.1:3500/health | jqPrimary config via environment (see memclawz/config.py):
| Variable | Default | Purpose |
|---|---|---|
QDRANT_HOST |
localhost |
Qdrant host |
QDRANT_PORT |
6333 |
Qdrant port |
QDRANT_COLLECTION |
memclawz_memories |
Collection name |
MEMCLAWZ_API_HOST |
127.0.0.1 |
API bind address |
MEMCLAWZ_API_PORT |
3500 |
API port |
MEMCLAWZ_API_KEYS |
empty | Bearer tokens for remote auth |
GEMINI_MODEL |
gemini-2.5-flash-lite |
Enrichment model |
- Local requests (
127.0.0.1,::1) bypass auth /healthis always open- Remote requests require
Authorization: Bearer <token> - Authenticated proxy available on port 13500
External fleet members can be granted write-only tokens that allow adding memories but block all read/search/list/delete operations. This enables a two-tier auth model:
| Tier | Permissions | Use Case |
|---|---|---|
| Full access | Read, write, search, list, delete, compact | Internal agents on trusted infrastructure |
| Write-only | POST /api/v1/add, POST /api/v1/add-direct only |
External fleet members contributing memories |
Security features (v11.2):
- Rate limiting on auth proxy — 5 failed auth attempts triggers a 5-minute IP block
- Token rotation — rotate tokens without downtime via config reload
- IP allowlist management — restrict proxy access to known IPs
memclawz-synccron module (v11.1) now works with write-only tokens for outbound sync
Lightweight cron-based memory sync between MemClawz instances. Replaces the old federation module.
# Install on any fleet node
cd ~/memclawz/sync
./install.sh # interactive setup + cron- Outbound: pushes new local memories to central
- Inbound: pulls cross-agent intelligence from central
- Dedup: skips already-synced memories
- Resilient: graceful on central downtime
See sync/README.md for full docs.
memclawz/
├── memclawz/
│ ├── __init__.py
│ ├── api.py
│ ├── classifier.py
│ ├── compactor.py
│ ├── compaction_cron.py
│ ├── config.py
│ ├── enrichment.py
│ ├── qdrant_store.py
│ ├── routing.py
│ ├── scoring.py
│ └── utils.py
├── sync/
│ ├── memclawz-sync.py
│ ├── install.sh
│ ├── README.md
│ └── .env (local config, gitignored)
├── docs/
├── .env
├── pyproject.toml
└── VERSION
MIT