← 返回 Skills 市场
kimmi2ue

Agent Memory Hierarchy

作者 kimmi2ue · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
115
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install agent-memory-hierarchy
功能描述
Structure an OpenClaw agent's memory like a computer — using a cache hierarchy (hot/warm/cold), a YAML fact store for directly addressable data, a lookup ind...
使用说明 (SKILL.md)

Agent Memory Hierarchy

Agents typically store everything as prose in a single MEMORY.md. This works but wastes tokens and makes retrieval fuzzy. This skill structures memory the way computers do: hot cache, warm storage, cold archives, typed data, and a lookup index.

Core Principle

Facts go in YAML. Narrative goes in prose. Everything gets an index.

Three reasons:

  1. YAML is ~40% more token-efficient than prose for the same information
  2. Specific facts become directly addressable — no semantic search needed
  3. Separation of concerns: behavioral rules, narrative context, and facts are distinct problems

The Three-Layer Architecture

Layer 1 — Hot Cache (always in context)

File: MEMORY.md

Contains only:

  • Identity summary (2-3 lines)
  • Behavioral rules (how the agent must behave)
  • Standing permissions
  • Narrative context that needs interpretation (relationships, mission, origin story)
  • Pointers to Layer 2

Does NOT contain: facts, dates, numbers, file paths, IDs, project statuses, todos.

Target size: under 80 lines / ~1000 tokens.

Layer 2 — Warm Storage (loaded on demand)

Files: memory/facts.yaml, memory/lookup-index.md, memory/project-*.md

facts.yaml — All structured factual data:

  • Identity facts (name, contact, IDs)
  • Dates and numbers (age, salary, target year, budget)
  • File paths and system config
  • Project statuses (one-line each, with pointer to full file)
  • Outstanding TODOs
  • Services and accounts

lookup-index.md — Explicit directory table:

| I need to know... | Go here |
|---|---|
| Contact info | memory/facts.yaml → identity |
| Project statuses | memory/facts.yaml → projects |
| Book research | workspace/book-research/ |

project-*.md — Full narrative project files, loaded only when working on that project.

Layer 3 — Cold Storage (rarely accessed)

Files: memory/YYYY-MM-DD.md (daily logs)

Raw session logs. Never loaded automatically. Retrieved only when investigating history or refreshing long-term memory.


Migration Process

Follow this order when converting an existing prose-only MEMORY.md:

Step 1: Audit existing MEMORY.md

Read the full file and categorize every piece of information:

  • Fact → moves to facts.yaml (name, email, date, number, path, ID, status)
  • Behavioral rule → stays in MEMORY.md
  • Narrative/context → stays in MEMORY.md (relationship descriptions, quotes, origin stories)
  • Project detail → moves to or stays in project-*.md

Step 2: Build memory/facts.yaml

Use this schema pattern:

# memory/facts.yaml
# Structured factual data — directly addressable, token-efficient
# Last updated: YYYY-MM-DD

identity:
  full_name: ...
  email: ...
  telegram_id: ...

health:
  condition: ...
  status: ...

technical:
  machine: ...
  os: ...
  workspace: ...

paths:
  api_keys: ...
  error_log: ...

projects:
  project_name: {file: memory/project-name.md, status: "one-line status"}

todos:
  - Todo item one
  - Todo item two

Rules for facts.yaml:

  • Flat where possible, nested where grouping helps
  • One-line values only — no multi-line prose
  • If a value needs explanation, it belongs in MEMORY.md prose instead
  • Add # Last updated: YYYY-MM-DD at top

Step 3: Build memory/lookup-index.md

Create a markdown table mapping "I need to know X" → exact file and section. Every project file, reference file, and key section should have an entry. This is your agent's O(1) lookup. When you need something, check here first.

Step 4: Rewrite MEMORY.md

Remove everything that moved to facts.yaml. What remains:

  • 2-3 line identity/mission summary
  • Behavioral rules (explicit, imperative)
  • Standing permissions
  • Narrative sections that require context to understand
  • Pointers: # Structured facts → memory/facts.yaml and # Find anything → memory/lookup-index.md

Step 5: Verify

After migration, confirm:

  • Every fact in old MEMORY.md is now in facts.yaml
  • lookup-index.md covers every project and reference file
  • MEMORY.md contains no facts (no dates, numbers, paths, IDs)
  • New MEMORY.md is under 80 lines
  • Agent can answer "where is X?" using lookup-index.md without searching

Using the Architecture Day-to-Day

At session start: Load MEMORY.md (hot cache) only.

When you need a specific fact: Check lookup-index.md → go directly to that file/section.

When working on a project: Load the specific project-*.md file.

When updating facts: Edit facts.yaml directly. No need to touch MEMORY.md.

When updating todos: Edit facts.yaml → todos. One place, always current.

Maintenance cadence:

  • After each session: update facts.yaml if any facts changed
  • Weekly: review MEMORY.md behavioral rules for accuracy
  • Monthly: read recent daily logs, distill lessons into MEMORY.md, archive old logs

What NOT to Structure

Some things resist YAML and belong in prose:

  • Relationship dynamics ("she calls me Mols, treat her like a friend not a user")
  • Emotional context ("Kim feels like the one who got skipped")
  • Mission statements and quotes
  • Lessons learned with nuance ("DALL-E 3 is inconsistent for coloring pages — use Canva AI instead")
  • Anything where the why matters as much as the what

When in doubt: if it would lose meaning as a key-value pair, keep it in prose.


Reference Files

  • references/facts-yaml-template.md — copy-paste starting template for facts.yaml
  • references/lookup-index-template.md — copy-paste starting template for lookup-index.md
安全使用建议
This skill appears safe to install as an instruction-only memory organizer. Before using it, decide what information should be allowed in persistent memory, avoid storing actual secrets or API keys, and review backups and migrated files so future agents do not rely on incorrect or overly sensitive context.
功能分析
Type: OpenClaw Skill Name: agent-memory-hierarchy Version: 1.0.0 The skill bundle provides a framework for organizing an agent's memory into a structured hierarchy to improve token efficiency. It is classified as suspicious because it explicitly instructs the agent to consolidate highly sensitive information—including API keys, telegram IDs, and system paths—into a single, predictable, plain-text YAML file (`memory/facts.yaml`) as shown in SKILL.md and the provided templates. While the behavior is aligned with the stated purpose and lacks evidence of intentional exfiltration, this practice creates a significant security vulnerability by centralizing secrets in an unencrypted and easily accessible format.
能力评估
Purpose & Capability
The skill's stated purpose is to restructure agent memory into hot/warm/cold layers, and the artifacts align with that purpose. It explicitly includes personal, health, account, project, and system facts in the memory structure, which is sensitive but purpose-aligned.
Instruction Scope
Instructions are scoped to reading and rewriting agent memory files such as MEMORY.md, memory/facts.yaml, lookup-index.md, project files, and daily logs. This is expected for the purpose, but users should review changes before relying on the migrated memory.
Install Mechanism
There is no install specification, no code, no dependencies, no required binaries, and no required environment variables.
Credentials
The skill does not request network access or credentials, but its templates include machine, OS, paths, services/accounts, and API-key path references. These are local sensitive details, though no secret values are requested.
Persistence & Privilege
The skill is explicitly about persistent memory and maintenance across sessions. It does not add privileged execution or background persistence, but the resulting files can influence future agent behavior.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install agent-memory-hierarchy
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /agent-memory-hierarchy 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release: introduces a hierarchical memory system for OpenClaw agents, inspired by computer cache architecture. - Separates memory into three tiers: hot cache (MEMORY.md for behavioral/narrative context), warm storage (structured YAML fact store and lookup index), and cold storage (daily session logs). - Shifts factual data to `facts.yaml` for space and retrieval efficiency; keeps narrative and behavioral content in concise prose files. - Provides a detailed migration process for converting prose-based memories to the new format. - Includes templates and rules for structuring data, ensuring fast, unambiguous memory retrieval and reduced token usage.
元数据
Slug agent-memory-hierarchy
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Agent Memory Hierarchy 是什么?

Structure an OpenClaw agent's memory like a computer — using a cache hierarchy (hot/warm/cold), a YAML fact store for directly addressable data, a lookup ind... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 115 次。

如何安装 Agent Memory Hierarchy?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install agent-memory-hierarchy」即可一键安装,无需额外配置。

Agent Memory Hierarchy 是免费的吗?

是的,Agent Memory Hierarchy 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Agent Memory Hierarchy 支持哪些平台?

Agent Memory Hierarchy 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Agent Memory Hierarchy?

由 kimmi2ue(@kimmi2ue)开发并维护,当前版本 v1.0.0。

💬 留言讨论