360 Secure SkillHub
360 安全技能中心

Memory Augment

该 Skill 以本地 YAML 存储和 Python 脚本实现智能体长期记忆:支持偏好、决策、上下文、学习四类记忆的存储、关键词与语义混合检索、标签与类型过滤、导出导入、过期归档和每轮自动上下文注入,并明确声明仅本地存储、不保存敏感数据(另含删除记忆命令)。

indigas
indigas
热度 36.33
最近更新 2026-05-11 17:43:59
分类:知识依赖:代码执行 / 读写文件应用场景:笔记整理 / 摘要总结 / 任务管理 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add claw-memory-augment
Metadata
name
memory-augment
description
Long-term memory system for OpenClaw agents. Store, retrieve, and query conversation history and learned information across sessions.

Memory Augment Skill

Provide long-term memory for OpenClaw agents. Store conversation history, learned facts, preferences, and context that persists across sessions.

Quick Start

# Install via clawhub
npx clawhub install memory-augment

# Trigger
"Remember that I prefer Python for automation scripts"
"Find all notes about my workspace setup"

Core Features

1. Long-Term Storage

Store any information that should persist:

  • User preferences: Coding style, workspace config, tool choices
  • Learned facts: Project details, technical decisions, patterns
  • Conversation history: Context from past sessions, decisions made
  • Task tracking: Todo items, progress, completed work

2. Semantic Search

Find stored information using natural language:

clawhub memory search "what did I decide about the inbox triage skill?"

3. Automatic Context Injection

Before each turn, automatically inject relevant memories:

{
  "context": {
    "recent_memories": [
      {"topic": "income", "content": "User approved inbox-triage for publishing"},
      {"topic": "workspace", "content": "OpenClaw running on marekserver"}
    ],
    "preferences": {
      "model": "local/qwen3.5-35B-A3B",
      "compute_tracked": true
    }
  }
}

4. Memory Expiry & Archiving

  • Temporary memories: Auto-expire after 7 days (session notes)
  • Permanent memories: Never expire (user preferences, core facts)
  • Archival: Compress old memories to reduce token usage

When to Use This Skill

✅ Need to remember user preferences across sessions ✅ Track conversation context over time ✅ Store learnings and decisions for future reference ✅ Query past information semantically ✅ Maintain agent personality and behavior consistency

❌ Not for storing sensitive data (passwords, API keys) ❌ Not for real-time data (current weather, live prices) ❌ Not for replacing database storage (structured data)

How It Works

Storage Layer

# ~/.memory-augment/storage.yaml
memories:
  - id: uuid-123
    content: "User prefers Python for automation"
    type: preference
    tags: ["coding", "python", "automation"]
    created: "2026-04-15T10:00:00Z"
    expires: null  # permanent
    score: 0.85   # confidence/relevance

  - id: uuid-124
    content: "Approved inbox-triage skill for publishing"
    type: decision
    tags: ["income", "skills", "approval"]
    created: "2026-04-15T20:37:00Z"
    expires: "2026-04-22T20:37:00Z"  # 7 days
    score: 0.95

Retrieval System

Uses hybrid search (keyword + semantic):

  1. Parse query for keywords
  2. Calculate relevance scores
  3. Return top-K relevant memories
  4. Inject into agent context

Scoring Algorithm

Memories are scored based on:

  • Recency: Newer = higher score
  • Tags match: Query tags vs memory tags
  • Type relevance: Preferences > decisions > context
  • Score boost: User-corrected memories boost their own score

Configuration

# ~/.memory-augment/config.yaml
storage:
  path: ~/.memory-augment/storage.yaml
  format: yaml  # or json

settings:
  max_memories: 1000
  default_expiry: 7  # days
  score_decay: 0.95  # daily decay factor
  
search:
  top_k: 20
  min_score: 0.3
  include_tags: true

auto_inject:
  enabled: true
  max_tokens: 5000
  inject_before: ["each_turn", "weekly_summary"]

Memory Types

Preference

User preferences, preferences, coding style, tool choices.

type: preference
tags: ["coding", "style"]
content: "Prefers concise code over comments"

Decision

Decisions made, approvals, blocking choices.

type: decision
tags: ["income", "skills"]
content: "Published inbox-triage to clawhub"

Context

Session context, project state, ongoing work.

type: context
tags: ["project", "setup"]
content: "Building memory-augment skill, 60% complete"

Learning

What the agent learned, patterns discovered, corrections.

type: learning
tags: ["pattern", "optimization"]
content: "Sub-agent spawning reduces context by 30%"

Commands

Store Memory

clawhub memory store "Remember my workspace is at /home/marek/.openclaw/workspace"
clawhub memory store "User prefers minimal markdown formatting" --tag preferences

Search Memories

clawhub memory search "what did I decide about income?"
clawhub memory search "all memories about skills" --tag skills

List Memories

clawhub memory list --type decision
clawhub memory list --since "2026-04-14"

Delete Memory

clawhub memory delete <uuid>
clawhub memory delete --tag "temporary" --older-than "7d"

Export/Import

clawhub memory export > memories.json
clawhub memory import < memories.json

Output Format

JSON

{
  "query": "income decisions",
  "results": [
    {
      "id": "uuid-123",
      "content": "Published inbox-triage skill",
      "score": 0.92,
      "tags": ["income", "skills"]
    }
  ],
  "total": 5,
  "took_ms": 45
}

Markdown

## Found 5 memories for "income decisions"

### 🎯 **Published inbox-triage skill** (score: 0.92)
**Type:** decision  
**Tags:** income, skills  
**Created:** 2026-04-15  
**Content:** Published inbox-triage skill to clawhub for passive income

Limitations

  • Token budget: Context injection respects 48k token ceiling
  • Search accuracy: Semantic search may miss nuanced queries
  • Privacy: Do not store sensitive data (passwords, secrets)
  • Sync: Local storage only (no cloud sync yet)
  • Expiry: Temporary memories auto-expire (configurable)

Integration

With Inbox Triage

# Inject triage context when discussing messages
auto_inject:
  triggers:
    - "inbox"
    - "messages"
    - "notification"
  memories:
    - "inbox-triage skill is complete and ready for publishing"

With Cron Manager

# Weekly memory summary
cron:
  schedule: "0 0 * * 0"  # Sunday midnight
  action: "memory summarize --output weekly-summary.md"

With Weather Alert

# Memory context for weather queries
auto_inject:
  triggers:
    - "weather"
    - "forecast"
  memories:
    - "User is in UTC timezone"
    - "Prefers concise weather summaries"

Iteration

Track search quality:

# Correct a bad search result
echo "CORRECT: uuid-123 - relevant to income query" >> ~/.memory-augment/corrections.log
echo "INCORRECT: uuid-124 - should not have matched" >> ~/.memory-augment/corrections.log

The system learns from corrections to improve scoring.


Roadmap

  • Basic storage system
  • Semantic search implementation
  • Automatic context injection
  • Multi-source sync (cloud backup)
  • Encrypted storage for sensitive data
  • Collaborative memories (shared between agents)

Built for the OpenClaw ecosystem.