← 返回 Skills 市场
jpmoregain-eth

Tiered Memory

作者 jpmoregain-eth · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
116
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install agent-tiered-memory
功能描述
Two-tier memory system for OpenClaw agents. Tier 0 = QMD semantic search for recent memories (7-14 days). Tier 1 = SQLite archive for long-term storage. Auto...
使用说明 (SKILL.md)

Tiered Memory Skill

Two-tier memory system combining OpenClaw's QMD semantic search with SQLite archival. Keeps recent memories fast and searchable while compressing old sessions for long-term storage.

Architecture

┌─────────────────────────────────────────┐
│  TIER 0: QMD Semantic Search            │
│  ├── Hot memory (7-14 days)             │
│  ├── GPU-accelerated vector search      │
│  └── Searches: MEMORY.md, memory/*.md   │
├─────────────────────────────────────────┤
│  TIER 1: SQLite Archive                 │
│  ├── Cold storage (14+ days)            │
│  ├── Compressed summaries + key facts   │
│  └── Structured queries via SQL         │
└─────────────────────────────────────────┘

Quick Start

1. Ensure QMD is Enabled

QMD comes with OpenClaw. Check status:

openclaw doctor

Should show QMD as available. If not, check ~/.openclaw/openclaw.json:

{
  "memory": {
    "qmd": {
      "enabled": true,
      "device": "cuda"
    }
  }
}

2. Set Up Archive Directory

mkdir -p ~/.openclaw/workspace/memory/archive

3. Install Cron Job (Auto-archive)

# Add to crontab
crontab -e

# Add this line for daily 2 AM archive
0 2 * * * /usr/bin/python3 ~/.openclaw/skills/tiered-memory/scripts/memory_archiver.py --days 14 >> ~/.openclaw/workspace/memory/archive.log 2>&1

4. Use in Your Agent

import sys
sys.path.insert(0, '~/.openclaw/skills/tiered-memory/scripts')
from tiered_memory import TieredMemory

mem = TieredMemory()

# Query across both tiers
results = mem.search("AgentBear project")

Manual Archive

# See what would be archived
python3 ~/.openclaw/skills/tiered-memory/scripts/memory_archiver.py --dry-run

# Archive files older than 14 days
python3 ~/.openclaw/skills/tiered-memory/scripts/memory_archiver.py

# Archive with custom threshold
python3 ~/.openclaw/skills/tiered-memory/scripts/memory_archiver.py --days 7

# Skip LLM (faster, basic summaries)
python3 ~/.openclaw/skills/tiered-memory/scripts/memory_archiver.py --skip-llm

Query Archives

# List all archived sessions
python3 ~/.openclaw/skills/tiered-memory/scripts/memory_archiver.py --list

# Search archived summaries
python3 ~/.openclaw/skills/tiered-memory/scripts/memory_archiver.py --search "AgentBear"

How It Works

Daily Flow

  1. During Day: Agent writes to memory/YYYY-MM-DD.md
  2. QMD Indexes: Real-time semantic indexing
  3. At 2 AM: Cron runs archiver
  4. Old Files: Summarized → SQLite → moved to archive/

Search Priority

When an agent searches memory:

  1. QMD search (Tier 0) - semantic, fuzzy, fast
  2. If not found or need history: Query SQLite (Tier 1)

Archive Format

Field Type Description
session_date DATE Original file date
summary TEXT LLM-generated summary
key_facts JSON Important facts extracted
topics JSON Tags/categories
message_count INT Lines in original file

Database Schema

CREATE TABLE archived_sessions (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    source_file TEXT NOT NULL,
    session_date DATE NOT NULL,
    summary TEXT NOT NULL,
    key_facts TEXT,  -- JSON array
    topics TEXT,     -- JSON array
    message_count INTEGER,
    archived_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_date ON archived_sessions(session_date);
CREATE INDEX idx_topics ON archived_sessions(topics);

Scripts

  • scripts/memory_archiver.py - Archive old files to SQLite
  • scripts/tiered_memory.py - Unified search across both tiers

Files

  • references/qmd-setup.md - QMD configuration details
  • references/archiver-api.md - Archiver script API reference

Notes

  • QMD requires CUDA GPU for best performance (falls back to CPU)
  • Archive uses Ollama for summarization (qwen2.5-coder:14b default)
  • Original files are preserved in archive/ folder
  • SQLite DB at ~/.openclaw/memory_archive.db

Troubleshooting

QMD not working? See references/qmd-setup.md

Archive failing? Check Ollama is running: ollama list

Want to restore archived file? Just move it back from memory/archive/ to memory/

安全使用建议
This skill appears to do what it claims: auto-archive old OpenClaw memory files into a local SQLite DB and optionally summarize them with Ollama. Before installing, check: 1) you are comfortable that the archiver will read and move files under ~/.openclaw/workspace/memory and will create ~/.openclaw/memory_archive.db; 2) if you care about privacy, use the --skip-llm flag or ensure your Ollama installation runs entirely locally (so summaries are not proxied off-machine); 3) inspect and, if desired, run the scripts manually before adding the cron entry; and 4) avoid running third-party curl|sh installers without review (the README suggests one for Ollama). If those points are acceptable, the skill is coherent and appropriate for its stated purpose.
功能分析
Type: OpenClaw Skill Name: agent-tiered-memory Version: 1.0.1 The tiered-memory skill implements a legitimate two-tier memory management system for OpenClaw agents, using SQLite for long-term archival and local Ollama instances for summarization. The code in memory_archiver.py and tiered_memory.py performs standard file operations and database queries within the expected ~/.openclaw directory, and the use of subprocess to call Ollama is consistent with the stated functionality without evidence of malicious intent or data exfiltration.
能力评估
Purpose & Capability
Name/description, required binaries (python3, ollama), and the included scripts all align: scripts scan ~/.openclaw/workspace/memory, summarize with Ollama, insert into a local SQLite DB, and move files to an archive directory. The requested binaries and filesystem paths are appropriate for a memory-archiver skill.
Instruction Scope
SKILL.md and the CLI/python examples limit actions to reading/writing files under ~/.openclaw, indexing/searching those files, and optionally invoking Ollama for summarization. The cron instructions explicitly run the provided archiver script. There are no instructions to read unrelated system config, other users' data, or to post content to unknown external endpoints.
Install Mechanism
This is instruction-only (no automated installer). The README suggests installing Ollama using the project's official install script (curl | sh) and pulling a model; that's a documented, optional step and uses the vendor's URL. No arbitrary archive downloads or obscure URLs are used by the skill itself. As always, running third-party install scripts has inherent risk and should be reviewed before execution.
Credentials
The skill requests no credentials or environment variables and confines work to ~/.openclaw paths and a local SQLite DB — proportionate to its purpose. One consideration: the archiver passes file content to the 'ollama' CLI. If Ollama is configured to run local models, content remains local; if an Ollama installation is configured to proxy or send data externally, sensitive memory content could be transmitted. The skill offers --skip-llm to avoid LLM summarization.
Persistence & Privilege
always is false and the skill does not request persistent platform-wide privileges. It creates and uses files under the user's home (~/.openclaw) only, and the cron job in SKILL.md is an explicit user action (not automatic). It does not attempt to modify other skills or system-wide agent settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install agent-tiered-memory
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /agent-tiered-memory 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
Fix: added ollama/python3 to requires.bins metadata, fixed inconsistent DB path (~/.agentbear → ~/.openclaw), declared external dependencies properly
v1.0.0
Two-tier memory system for OpenClaw agents. Tier 0 = QMD semantic search for recent memories. Tier 1 = SQLite archive for long-term storage. Auto-archives with LLM summarization.
元数据
Slug agent-tiered-memory
版本 1.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Tiered Memory 是什么?

Two-tier memory system for OpenClaw agents. Tier 0 = QMD semantic search for recent memories (7-14 days). Tier 1 = SQLite archive for long-term storage. Auto... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 116 次。

如何安装 Tiered Memory?

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

Tiered Memory 是免费的吗?

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

Tiered Memory 支持哪些平台?

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

谁开发了 Tiered Memory?

由 jpmoregain-eth(@jpmoregain-eth)开发并维护,当前版本 v1.0.1。

💬 留言讨论