此文件控制什么
MEMORY.md 是你的智能体的持久知识库——在上下文窗口重置和会话边界之后仍然存活的事实、偏好和习得行为。上下文窗口会填满,会话会重置;MEMORY.md 是留存下来的东西。没有它,你的智能体在每次会话之间都会忘记一切,重复相同的问题,失去所有积累的知识。
MEMORY.md 是 OpenClaw 和 Hermes 运行时都支持的仅有的三个文件之一(另外两个是 SOUL.md 和 USER.md)。运行时在每次会话开始时加载记忆条目,并在整个对话过程中使其可用。会话结束时,蒸馏协议决定哪些新知识被保留、哪些被更新、哪些被丢弃。
两个字段——memory(铁律事实)和 memoryDistillation(更新这些事实的协议)——共同构成一个知识生命周期。没有蒸馏协议的记忆条目会变得陈旧。没有结构良好的初始记忆的蒸馏协议则无从工作。两者必须一起配置才能实现有效的长期记忆。
为什么重要: Context windows fill up and sessions reset. MEMORY.md is what survives.
逐字段详解
定义智能体行为的 2 个字段
memory必填Permanent facts and knowledge the agent must always remember.
memoryDistillation必填Rules for how the agent condenses and updates its long-term memory.
实际配置示例
## memory
- Firm: Whitfield & Associates, Manchester. Senior Partner: Sarah Whitfield. 4 associates, 3 admin staff.
- Financial year end: 5 April (personal tax), various dates for corporate clients (see client list)
- Key HMRC deadlines: SA filing 31 Jan, CT600 12 months after period end, VAT quarterly
- Current corporation tax rate: 25% (profits over £250k), 19% (small profits rate under £50k), marginal relief between
- Anti-avoidance: firm policy is never to recommend schemes caught by GAAR
- [2026-03-15] Budget 2026: new digital services reporting requirement effective April 2027
- [2026-04-01] Client Meridian Ltd: changed year-end from March to December
## memoryDistillation
After each session: extract any new tax positions researched, client-specific decisions, deadline changes, or Budget updates. Date-stamp all new entries with [YYYY-MM-DD]. Remove resolved deadline items after the filing date passes. Flag any entry older than 6 months for review. Priority: P1 = regulatory changes, P2 = client-specific facts, P3 = general research findings, P4 = procedural notes.常见错误
将 MEMORY.md 当作对话日志
记忆应该包含提炼后的事实和决策,而非原始对话记录。倾倒完整对话会浪费 token 并拖慢检索速度。每条记忆条目都应该是一个独立的、可复用的事实。
未定义蒸馏协议
没有明确的保留、更新和丢弃规则,记忆条目会无限积累。智能体的上下文被过时信息填满,重要事实被噪音淹没。
未给条目加日期标记
没有日期的记忆条目没有过期信号。智能体无法区分昨天记录的事实和六个月前的事实。日期标记使相关性评分和陈旧性检测成为可能。
当作知识库的替代品使用
MEMORY.md 用于运营记忆——关于你特定业务的事实,而非通用领域知识。将维基百科式的内容填入其中会浪费有限的记忆预算,并稀释真正重要的事实。
SetupClaw 如何处理
记忆架构是智能体部署中最被低估的方面之一。我们的专家会举办一次记忆架构研讨会,识别你的智能体从第一天起就需要的关键事实,然后设计一套蒸馏协议来保持记忆的新鲜度和相关性。
记忆架构研讨会 + 初始事实加载 + 带 P1-P4 优先级系统的蒸馏协议
以上全部 + 带日期标记和来源归属的结构化格式 + 30 天蒸馏审查
以上全部 + 90 天深度蒸馏审查 + 重要性加权保留策略
- 两个字段均已配置,包含结构化的、带日期标记的条目
- 已建立 P1-P4 优先级系统用于蒸馏
- 从入职发现中加载了初始知识库
- 蒸馏协议已通过模拟会话数据测试
- 审查计划已记录
第 1 天加载初始记忆。第 2-3 天验证蒸馏协议。第 30 天首次审查(Standard+)。
进阶主题
FIFO 与重要性加权蒸馏策略
默认的蒸馏策略是 FIFO(先进先出)——当记忆已满时移除最旧的条目。对于大多数业务部署,重要性加权蒸馏更优:为条目分配优先级(P1-P4),较低优先级的条目在较高优先级之前被丢弃,无论其时间先后。这确保了 6 个月前的关键法规变更被保留,而昨天的常规程序备注可以被丢弃。
## memoryDistillation
Priority-based retention:
- P1 (regulatory/legal changes): retain indefinitely until superseded
- P2 (client/business-specific facts): retain for 12 months, then review
- P3 (general findings): retain for 6 months, then archive
- P4 (procedural notes): retain for 30 days, then auto-discard
When memory budget exceeded: discard lowest priority first, then oldest within tier.配置示例
Persona A — Meridian首席参谋
# MEMORY.md -- Long-Term Memory
## memory
- Principal: Alex, CEO/Founder. Series B. 80-person organisation.
- Board meeting schedule: quarterly (March, June, September, December)
- Current OKR cycle: Q2 2026 — focus on international expansion and Series C preparation
- Direct reports to principal: VP Engineering (Sam), VP Sales (Jordan), VP Product (Chris), Head of People (Dana)
- Decision threshold: principal approves anything over £50k or affecting >10 people
- [2026-04-01] New investor reporting format requested by lead VC
## memoryDistillation
After each session: extract decisions, commitments, risks, stakeholder context. Remove resolved items. Date-stamp all new entries. Priority: P1 = board/investor commitments, P2 = cross-functional decisions, P3 = stakeholder context, P4 = procedural.Persona B — Axiom (增长黑客)
# MEMORY.md -- Long-Term Memory
## memory
- Product: B2B SaaS, £1.6M ARR, 340 active accounts
- Top acquisition channel: organic search (42% of new signups)
- 30-day retention: 68% (target: 80%)
- Winning experiments: simplified onboarding (+12% activation), annual pricing default (+22% LTV)
- Failing experiments: referral programme (0.3% participation rate after 60 days)
- [2026-03-15] Pricing page redesign A/B test launched — results expected April 15
## memoryDistillation
After each session: append winning results, updated benchmarks, new hypotheses. Archive superseded data. Date-stamp all entries. Priority: P1 = active experiment results, P2 = benchmark updates, P3 = new hypotheses, P4 = archived experiments.Persona C — Lumen (科研人员)
# MEMORY.md -- Long-Term Memory
## memory
- Research domain: computational biology, protein folding, drug discovery
- Current grant: Wellcome Trust, 3-year programme ending December 2027
- Key collaborators: Prof. Chen (UCL), Dr. Martinez (Cambridge), Dr. Okafor (Oxford)
- Citation style: OSCOLA for legal, APA 7th for scientific publications
- Established finding: AlphaFold3 accuracy threshold sufficient for initial screening (>92% confidence)
- [2026-03-01] New preprint on mRNA delivery mechanisms — flagged for full review
## memoryDistillation
After each session: append high-quality sources with full citations, updated consensus positions, revised evidence gaps. Archive findings superseded by newer studies. Date-stamp all entries. Priority: P1 = paradigm-shifting findings, P2 = relevant new publications, P3 = methodology notes, P4 = administrative.Persona D — Narrative (内容创作者)
# MEMORY.md -- Long-Term Memory
## memory
- Brand voice: authoritative but approachable, B2B fintech, never salesy
- Target audience: CFOs and finance directors at mid-market companies (50–500 employees)
- Top content types: long-form guides (2,500+ words), LinkedIn thought leadership, weekly newsletter
- Evergreen pillars: cash flow management, regulatory compliance, financial automation
- Topics to avoid: cryptocurrency, specific stock recommendations, competitor disparagement
- [2026-04-01] Q2 editorial calendar finalised — focus on regulatory compliance series
## memoryDistillation
After each session: update calendar status, performance data, winning formats. Archive content older than 12 months. Date-stamp all entries. Priority: P1 = editorial calendar changes, P2 = performance data, P3 = audience insights, P4 = format notes.Persona E — Architect (首席工程师)
# MEMORY.md -- Long-Term Memory
## memory
- Tech stack: TypeScript/Node.js backend, React frontend, PostgreSQL, Redis, AWS EKS
- Active ADRs: ADR-042 (event sourcing migration), ADR-043 (API versioning strategy)
- Known tech debt: legacy auth service (estimated 3 sprints to replace), missing integration tests for payment flow
- SLA targets: 99.95% uptime, p99 latency <200ms, zero data loss
- [2026-03-20] Major incident: database failover took 12 minutes (target: <2 minutes) — post-mortem pending
- [2026-04-05] Security audit findings: 2 HIGH, 5 MEDIUM — remediation plan due April 20
## memoryDistillation
After each session: record ADRs, incidents, tech debt discoveries, security findings. Archive completed items. Date-stamp all entries. Priority: P1 = active incidents and security findings, P2 = ADR decisions, P3 = tech debt items, P4 = routine maintenance notes.