← Back to Skills Marketplace
kimmi2ue

Agent Memory Hierarchy

by kimmi2ue · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
115
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install agent-memory-hierarchy
Description
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...
README (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
Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install agent-memory-hierarchy
  3. After installation, invoke the skill by name or use /agent-memory-hierarchy
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
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.
Metadata
Slug agent-memory-hierarchy
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is 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... It is an AI Agent Skill for Claude Code / OpenClaw, with 115 downloads so far.

How do I install Agent Memory Hierarchy?

Run "/install agent-memory-hierarchy" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Agent Memory Hierarchy free?

Yes, Agent Memory Hierarchy is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Agent Memory Hierarchy support?

Agent Memory Hierarchy is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Agent Memory Hierarchy?

It is built and maintained by kimmi2ue (@kimmi2ue); the current version is v1.0.0.

💬 Comments