← 返回
未分类 中文

Memory Guardian

Memory health monitoring, integrity checks, and 3-layer memory architecture for AI agents. Use when agents need to prevent memory loss, detect context overfl...
内存健康监控、完整性检查及三层记忆架构,用于AI智能体防止记忆丢失、检测上下文溢出等场景。
dodge1218 dodge1218 来源
未分类 clawhub v1.1.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 379
下载
💾 0
安装
1
版本
#latest

概述

Memory Guardian

Prevent memory loss and context overflow. 3-layer architecture with automated health checks.

Architecture

Layer 1: Working Memory (session files, 7-day retention)
    ↓ promote durable facts before deletion
Layer 2: Permanent Memory (never pruned, manual only)
    ↓ migrate to vector store at 5,000+ lines
Layer 3: Archive (batch docs, value stacks — disk forever)

Health Checks

Run python3 scripts/memory_check.py on heartbeat or manually. Catches:

  • Files over 300 lines (split needed)
  • Total memory over 3,000 lines (yellow alert → prune)
  • Stale session files (>7 days → promote + delete)
  • Duplicate content across files
  • MEMORY.md index inconsistency
  • Orphan files not referenced anywhere

Danger Zones

Total LinesRiskAction
---------------------------
< 2,000🟢 GreenNormal operations
2,000-3,000🟡 YellowPrune sessions, compress old entries
3,000-5,000🟠 OrangeAggressive promotion to permanent, archive sessions
5,000+🔴 RedSemantic search returns noise → migrate to FAISS

Promotion Protocol

Before deleting ANY session file, extract:

  1. Credentials/keys → permanent (NEVER lose these)
  2. Architecture decisions → permanent/business-strategy.md
  3. Infrastructure changes → permanent/outreach-infrastructure.md
  4. New project summaries → permanent/projects/[name].md
  5. User preferences → permanent/user-system.md

Everything else (debug logs, intermediate results) → delete.

Migration Triggers

TriggerAction
-----------------
permanent/ > 5,000 linesMigrate to FAISS vector store
Batch value-stack > 100 itemsAdd embeddings for semantic retrieval
ChatGPT corpus loadedFAISS mandatory
Cross-batch connections > 50Consider Neo4j knowledge graph

Emergency Recovery

Everything is git-tracked. If memory corrupts:

  1. git log memory/ → find last good state
  2. git checkout -- memory/ → restore
  3. Rebuild MEMORY.md index from ls memory/permanent/

Context Budget

ComponentTokensNotes
--------------------------
System prompt~2,000Fixed
MEMORY.md~1,500Keep lean
Active session~1,000Today only
memory_search~500On-demand
Total overhead~5,000Of 200K+ available

版本历史

共 1 个版本

  • v1.1.0 当前
    2026-05-07 06:17 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

self-improving agent

pskoett
记录自身发现以实现自我改进的技能
★ 4,153 📥 925,468
ai-agent

Find Skills

root
帮助用户发现和安装智能体技能,当用户询问如「如何做X」、「找X的技能」、「有能做...的吗」等问题时
★ 1,507 📥 567,173
dev-programming

Rate Limit Guard

dodge1218
防止429重试循环和令牌浪费。在昂贵的API调用前或触发速率限制后使用。强制执行预检、退避和上下文收缩。
★ 0 📥 549