AutoMem scripts

June 22, 2026 · View on GitHub

Operational, migration, recovery, and evaluation tooling for an AutoMem instance. This file is the catalog — the single place to find "what scripts exist and when do I run each one." For the narrative runbooks (why and when), see the docs portal; for exact flags, run a script with --help or read its docstring header.

How to read this

Most Python scripts are self-documenting: run python scripts/<name>.py --help, or read the docstring at the top of the file. Most connect to FalkorDB (and Qdrant) using credentials from .env in the repo root or ~/.config/automem/.env. A handful of harness scripts are fronted by make targets (noted inline).

Each script is tagged by lifecycle — the single most important thing to know before running it:

TagMeaning
routineSafe to run repeatedly as normal operations.
one-timeRun once per instance or per upgrade. Idempotent, but not part of day-to-day ops. See docs/MIGRATIONS.md.
recoveryBreak-glass. Only after data loss or corruption. See docs/MONITORING_AND_BACKUPS.md.
devLocal development / deployment helpers.
bench · labContributor evaluation and recall-tuning harnesses. Not needed to run AutoMem. See docs/TESTING.md and docs/RECALL_QUALITY_LAB.md.

Routine operations

Run these as part of normal upkeep.

ScriptLifecycleWhat it does
backup_automem.pyroutineTimestamped FalkorDB + Qdrant backup; optional S3 upload and old-backup cleanup. Cron-friendly. --s3-bucket, --cleanup --keep N.
restore_from_backup.pyroutine · recoveryRestore FalkorDB + Qdrant from a backup (local snapshot or downloaded API tarball). --backup-timestamp, --backup-dir snapshot.tar.gz, --dry-run.
health_monitor.pyroutineBackground service: watches FalkorDB/Qdrant health, checks graph↔vector consistency, triggers recovery, alerts. --interval 300. Containerized via Dockerfile.health-monitor. See docs/HEALTH_MONITORING.md.
automem_watch.pyroutineReal-time terminal UI over the SSE event stream; flags garbage-write patterns and consolidation timing. --url, --token.
audit_relevance.pyroutineAudit the relevance_score distribution from a backup file (default) or a live instance (--live).
reembed_embeddings.pyroutineRe-embed all memories and upsert vectors into Qdrant using the configured provider. --batch-size, --limit. Used after provider/dimension changes — see docs/MIGRATIONS.md.
reclassify_with_llm.pyroutineReclassify fallback type='Memory' records via the configured classification LLM. --provider; env CLASSIFICATION_MODEL / CLASSIFICATION_BASE_URL / CLASSIFICATION_API_KEY.
reenrich_batch.pyroutineRe-run enrichment over a batch of memories with current classification logic.

browse_memories.py — read-only database browser dev

Interactive CLI over the production FalkorDB graph + Qdrant vectors. Connects with .env credentials and never modifies data. Four subcommands:

# search — by text, date range, type, tag, importance
python scripts/browse_memories.py search --text "Eva" --from 2025-10
python scripts/browse_memories.py search --type Decision --min-importance 0.8 --sort relevance -n 50
python scripts/browse_memories.py search --text "old project" --include-archived

# inspect — full record for one memory (4+ char id prefix works)
python scripts/browse_memories.py inspect 2751e70e

# stats — overview; --full adds a FalkorDB↔Qdrant consistency check
python scripts/browse_memories.py stats --full

# diagnose — why a memory isn't surfacing in recall (decay, access,
# relationships, importance floor, embedding quality, current weights)
python scripts/browse_memories.py diagnose 2751e70e

inspect shows full content, all FalkorDB properties, Qdrant presence/payload, and every graph relationship. diagnose reports issues at [CRITICAL] / [WARNING] / [INFO] severity.


One-time migrations

Run once per instance or when upgrading. Idempotent and safe to re-run, but not part of routine ops. Full runbook: docs/MIGRATIONS.md.

ScriptLifecycleWhat it does
migrate_mcp_sqlite.pyone-timeImport the legacy MCP sqlite_vec.db memory store into AutoMem via the API, preserving timestamps/tags/importance. --db, --automem-url, --api-token, --dry-run.
migrate_entity_nodes.pyone-timePromote entity:{category}:{slug} tags on Memory nodes into first-class Entity nodes linked by REFERENCED_IN. --dry-run. (0.16.0)
backfill_tag_prefixes.pyone-timeCompute and backfill tag_prefixes in FalkorDB + Qdrant from existing tags (keeps prefix-match recall consistent).
rescore_relevance.pyone-timeRecompute every relevance_score with the corrected decay formula (undoes the old over-aggressive 0.1 rate). --dry-run, --target.
cleanup_memory_types.pyone-timeReclassify invalid memory types (e.g. session_start, interaction) back to valid types. No flags; reads .env.

scripts/lab/repair_entity_tags.py (lab, below) is the companion repair tool for entity-tag noise on a local clone before promoting entity nodes.


Break-glass recovery

Only reach for these after data loss or corruption. See docs/MONITORING_AND_BACKUPS.md.

ScriptLifecycleWhat it does
recover_from_qdrant.pyrecoveryRebuild the FalkorDB graph from Qdrant: reads every vector's payload and re-inserts via the API, which regenerates relationships. No flags; reads .env.
deduplicate_qdrant.pyrecoveryRemove duplicate Qdrant points (e.g. after a recovery run double-inserted). --dry-run, --auto-confirm.
restore_from_backup.pyrecovery · routineSee Routine operations above.

Developer & deployment

ScriptLifecycleWhat it doesMake target
bootstrap_dev.shdevCreate .venv (Python 3.12), refresh venv -> .venv, install dev deps + pre-commit hooks.make install
deploy_check.shdevCompare the live Railway deployment commit against origin/main to catch a silently disconnected GitHub integration. DEPLOY_CHECK_QUIET=1 for CI.make deploy-check

Benchmark harness — scripts/bench/

Snapshot-based LoCoMo / LongMemEval evaluation. See docs/TESTING.md.

ScriptWhat it doesMake target
bench/ingest_and_snapshot.shIngest a benchmark dataset into Docker AutoMem and snapshot the volumes (run once).make bench-ingest BENCH=locomo
bench/restore_and_eval.shRestore a snapshot and evaluate a config (no re-ingest).make bench-eval BENCH=locomo CONFIG=baseline
bench/compare_configs.shA/B two scoring configs against the same snapshot.make bench-compare
bench/compare_branch.shCompare a git branch against main on a snapshot.make bench-compare-branch BRANCH=…
bench/compare_results.pySide-by-side table of two result JSON files. --baseline, --test, --output.
bench/analyze_locomo_results.pyMarkdown failure report from a LoCoMo results JSON. --output. (0.16.0)
bench/health_check.pyPost-restore diagnostics: score distribution, entity quality, latency, precision on curated queries.make bench-health
run_longmemeval_watch.shLongMemEval with persistent logging + desktop completion/crash notifications.make test-longmemeval-watch

Recall Quality Lab — scripts/lab/

Data-driven recall scoring experiments against a clone of production. Full workflow: docs/RECALL_QUALITY_LAB.md.

ScriptWhat it doesMake target
lab/clone_production.shClone production data into an isolated local Docker stack (direct DB backup, or --restore-only from a saved API tarball; supports custom ports for parallel sweeps).make lab-clone
lab/create_test_queries.pyGenerate a natural-question test set from local memories (via GPT-4o-mini). --count, --output, --api-url.make lab-queries
lab/run_recall_test.pyRun a test set under a config, compute Recall@K / MRR / NDCG, A/B compare, and sweep a parameter. --config, --compare, --sweep.make lab-test · make lab-compare · make lab-sweep
lab/repair_entity_tags.pyAudit → plan → execute/rollback repair of noisy generated entity tags on a clone. --mode audit|execute|rollback. (0.16.0)
lab/lab_metrics.pyLibrary module (not a CLI): pure, deterministic IR scoring functions (Recall@K, MRR, NDCG, distractor rate). Imported by run_recall_test.py. (0.16.0)
lab/lab_corpus.pyLibrary module (not a CLI): recall/corpus HTTP helpers behind injectable clients for unit-testable lab logic. (0.16.0)
lab/configs/JSON scoring-weight overrides for A/B testing (baseline.json, issue78_*.json).

Shared

FileWhat it is
lib/common.shShell helpers (color codes, wait_for_api) sourced by the bench/ scripts.
archive/Retired one-off scripts kept for reference (e.g. dated release-sweep summarizers). Not maintained.

See also