Loading repository data…
Loading repository data…
mage0535 / repository
🧠 Production-grade memory sidecar for AI agents — gbrain + Hindsight + 3-tier recall. Agent-agnostic, battle-tested. | 生产级外挂记忆系统,兼容Hermes/Claude/Cursor等任意AI智能体
v3.5.2 adds privacy-safe synthetic and private memory evaluation registries, five quality metrics, additive governance policy metadata, and dry-run-first gbrain edge planning. See the v3.5.2 release notes.
The follow-up memory quality optimization adds canonical runtime path resolution, evaluation trend comparison, private registry linting, policy validity/conflict metadata, gbrain plan summaries, and an operator report. See the optimization report.
In production, runtime scripts execute from $AGENT_HOME/scripts. The sibling $AGENT_HOME/memory-sidecar directory supplies additive Python modules, docs, and installer assets. The memory-quality cron block is registered in a paused remediation state by default and is explicitly unpaused only after operational review.
A publishable, agent-agnostic memory sidecar for Hermes, Claude Code, Codex, Cursor, and similar agents.
Memory Sidecar is an external memory system that runs next to an AI agent without patching the agent itself. It reads the agent's data directory, archives sessions, builds long-term knowledge, and injects relevant recall back into future work.
Release 3.5.1 is the operational hardening release for the current public architecture:
AGENT_HOMEThis repository is suitable for public install feedback from technical users running their own Hindsight + gbrain + PostgreSQL environment.
Long-running AI agents tend to lose useful context when work spans many sessions, projects, and knowledge sources. A single prompt-local memory file is not enough for durable recall, and operators need to know when archival, recall, or compaction silently stops working.
Memory Sidecar was built to make memory an installable, observable sidecar rather than a hidden agent-core modification.
AGENT_HOME, state.db, sessions, Hindsight, gbrain, and markdown notes.The sidecar follows a simple operational loop:
AGENT_HOMEThe sidecar is designed to improve memory in three concrete ways:
v3.5.1 intentionally separates the generic sidecar from host-specific operations:
memory_watermark.py and memory_snapshot_backup.py.Those two operational helpers are Hermes-oriented maintenance scripts with stronger host assumptions, so they are not installed by default in the public multi-agent path.
3.9+16state.db and session filesSupported examples:
git clone https://github.com/mage0535/hermes-memory-installer.git
cd hermes-memory-installer
export AGENT_HOME="$HOME/.hermes" # or ~/.claude, ~/.cursor, ~/.agent, etc.
./install.sh
Non-interactive mode:
./install.sh --noninteractive --agent-home "$HOME/.my-agent"
The installer supports three install modes for dependency assistance:
--install-mode 3
Default. Tries the most automatic dependency bootstrap path first.--install-mode 2
Guided dependency assistance. Shows the recommended commands and lets you continue step by step.--install-mode 1
Detection-only mode. Does not change the system and prints what is missing.If mode 3 fails, re-run with:
./install.sh --install-mode 2
If mode 2 still does not work, fall back to:
./install.sh --install-mode 1
The installer also supports bilingual output:
./install.sh --lang en
./install.sh --lang zh
When --lang is omitted, the installer falls back to locale detection.
After install:
python3 "$AGENT_HOME/scripts/session_to_gbrain.py" --resume
python3 "$AGENT_HOME/scripts/memory_maintenance_cycle.py"
python3 "$AGENT_HOME/scripts/sidecar_acceptance_check.py"
The public installer deploys 28 runtime, support, and observability scripts into $AGENT_HOME/scripts/.
Entry scripts:
session_to_gbrain.pymemory_governance_rebuild.pymemory_guardian.pymemory_family_registry.pytiered_context_injector.pymemory_maintenance_cycle.pysidecar_acceptance_check.pyarchive_sessions.pyauto_session_summary.pygbrain_deorphan_index.pymemory_observability_report.pymemory_storage_cross_check.pyruntime_drift_check.pygbrain_stale_maintenance.pyalert_queue.pyalert_webhook_receiver.pymetrics_dashboard.pymetrics_dashboard_server.pyopenmetrics_exporter.pyslo_rollup.pyprofile_isolation_soak.pysynthetic_recall_benchmark.pyhindsight_security_audit.pySupport modules:
state_db_schema.pyknowledge_notes.pyrecall_samples.pylangsmith_monitor.pylangsmith_task_wrapper.pylangsmith_trend_report.pyOptional repository-only helpers:
memory_watermark.pymemory_snapshot_backup.pyinstaller/ contains the install entrypoint and environment checksscripts/ contains the runtime sidecar entry scripts and support modulesskills/ contains agent-side memory skillstemplates/ contains reusable memory templatesdocs/ contains planning, verification, and release notesMemory Sidecar can consume curated markdown knowledge in addition to session history.
By default, governance rebuild checks:
$AGENT_HOME/knowledge/notes$AGENT_HOME/knowledge/wiki/wikiThese notes are indexed into a dedicated knowledge recall layer and participate in fused retrieval alongside session search, Hindsight facts, and gbrain results.
For a larger knowledge workflow, pair this project with Knowledge-and-Memory-Management.
That project extends the sidecar with:
Practical boundary:
hermes-memory-installer is the memory sidecar runtime and installerKnowledge-and-Memory-Management is the upstream knowledge capture and curation layerUsed together, KMM supplies curated notes and source material, and Memory Sidecar turns that material into recallable context for agents.
Semantic recall is optional but recommended. The installer records the selected model, while the embedding service itself is run separately.
The installer keeps the interactive embedding model selection flow.
--embedding.Recommended default:
intfloat/multilingual-e5-smallCommon alternatives:
BAAI/bge-small-zh-v1.5: lightweight Chinese-first deployments.paraphrase-multilingual-MiniLM-L12-v2: mature sentence-transformers ecosystem.Alibaba-NLP/gte-multilingual-base: higher quality when RAM headroom is available.sentence-transformers/LaBSE: cross-language alignment.BAAI/bge-m3: maximum recall quality with higher resource cost.alert_queue.py normalizes health artifacts into a local queue. alert_webhook_receiver.py provides a real local webhook target, can forward action-needed alerts to generic webhooks, Slack, Feishu/Lark, DingTalk, or Telegram via private environment variables, and can replay dead-letter rows after a downstream outage.
Alert text is language-adaptive:
payload.lang / payload.preferred_lang / payload.user_lang takes priorityMEMORY_ALERT_LANG, MEMORY_UI_LANG, or system locale is usedzh and enTelegram note:
telegram_language_sync.py reads bot updates, stores chat_id -> lang, and later outbound alerts reuse that language automatically.config/alert_recipients.example.json and place the real file in $AGENT_HOME/private/alert-recipients.json.metrics_dashboard.py renders a static HTML dashboard. metrics_dashboard_server.py can serve HTML, /api/status JSON, and /metrics OpenMetrics text behind a bearer/query token, and binds to 127.0.0.1 by default. slo_rollup.py summarizes acceptance rate, alert queue growth, dead-letter replay success, and recall latency quantiles into slo-rollup-latest.json. synthetic_recall_benchmark.py provides a private-data-free recall regression fixture for CI.
For shell and monitoring probes:
hermes-memory status
hermes-memory slo-rollup
hermes-memory openmetrics
Grafana dashboards included in the repository:
A ready-to-run Prometheus/Grafana stack template is included in deploy/observability/README.md.
That stack now also includes:
prometheus-rules.yml for default alert rulesprovision_dashboards.py to import the dashboards through the Grafana API and set the default Grafana home dashboardReverse proxy templates are available in [docs/dashboard-reverse-proxy.md](docs/dashboard-re