home / skills / openclaw / skills / triple-memory-skill

triple-memory-skill skill

/skills/ktpriyatham/triple-memory-skill

This skill manages persistent agent memory across sessions by integrating LanceDB auto-recall, Git-Notes memory, and file workspace search for cohesive context.

npx playbooks add skill openclaw/skills --skill triple-memory-skill

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
4.6 KB
---
name: triple-memory
version: 1.0.0
description: Complete memory system combining LanceDB auto-recall, Git-Notes structured memory, and file-based workspace search. Use when setting up comprehensive agent memory, when you need persistent context across sessions, or when managing decisions/preferences/tasks with multiple memory backends working together.
metadata:
  clawdbot:
    emoji: "đź§ "
    requires:
      plugins:
        - memory-lancedb
      skills:
        - git-notes-memory
---

# Triple Memory System

A comprehensive memory architecture combining three complementary systems for maximum context retention across sessions.

## Architecture Overview

```
User Message
     ↓
[LanceDB auto-recall] → injects relevant conversation memories
     ↓
Agent responds (using all 3 systems)
     ↓
[LanceDB auto-capture] → stores preferences/decisions automatically
     ↓
[Git-Notes] → structured decisions with entity extraction
     ↓
[File updates] → persistent workspace docs
```

## The Three Systems

### 1. LanceDB (Conversation Memory)
- **Auto-recall:** Relevant memories injected before each response
- **Auto-capture:** Preferences/decisions/facts stored automatically
- **Tools:** `memory_recall`, `memory_store`, `memory_forget`
- **Triggers:** "remember", "prefer", "my X is", "I like/hate/want"

### 2. Git-Notes Memory (Structured, Local)
- **Branch-aware:** Memories isolated per git branch
- **Entity extraction:** Auto-extracts topics, names, concepts
- **Importance levels:** critical, high, normal, low
- **No external API calls**

### 3. File Search (Workspace)
- **Searches:** MEMORY.md, memory/*.md, any workspace file
- **Script:** `scripts/file-search.sh`

## Setup

### Enable LanceDB Plugin
```json
{
  "plugins": {
    "slots": { "memory": "memory-lancedb" },
    "entries": {
      "memory-lancedb": {
        "enabled": true,
        "config": {
          "embedding": { "apiKey": "${OPENAI_API_KEY}", "model": "text-embedding-3-small" },
          "autoRecall": true,
          "autoCapture": true
        }
      }
    }
  }
}
```

### Enable Auto Memory Flush (Pre-Compaction)
Add to your Clawdbot config to automatically preserve context before compaction:
```json
{
  "agents": {
    "defaults": {
      "compaction": {
        "mode": "safeguard",
        "memoryFlush": {
          "enabled": true,
          "softThresholdTokens": 8000,
          "systemPrompt": "Session nearing compaction. Preserve context using triple memory system (git-notes, LanceDB, files).",
          "prompt": "Context is at ~80%. Write session summary to memory/YYYY-MM-DD.md, update MEMORY.md if needed, store key facts to git-notes. Reply NO_REPLY when done."
        }
      }
    }
  }
}
```

This triggers automatic memory dump when context reaches ~80%, before any information is lost to compaction.

### Install Git-Notes Memory
```bash
clawdhub install git-notes-memory
```

### Create File Search Script
Copy `scripts/file-search.sh` to your workspace.

## Usage

### Session Start (Always)
```bash
python3 skills/git-notes-memory/memory.py -p $WORKSPACE sync --start
```

### Store Important Decisions
```bash
python3 skills/git-notes-memory/memory.py -p $WORKSPACE remember \
  '{"decision": "Use PostgreSQL", "reason": "Team expertise"}' \
  -t architecture,database -i h
```

### Search Workspace Files
```bash
./scripts/file-search.sh "database config" 5
```

### Conversation Memory (Automatic)
LanceDB handles this automatically. Manual tools:
- `memory_recall "query"` - search conversation memory
- `memory_store "text"` - manually store something
- `memory_forget` - delete memories (GDPR)

## Importance Levels

| Flag | Level | When to Use |
|------|-------|-------------|
| `-i c` | Critical | "always remember", explicit preferences |
| `-i h` | High | Decisions, corrections, preferences |
| `-i n` | Normal | General information |
| `-i l` | Low | Temporary notes |

## When to Use Each System

| System | Use For |
|--------|---------|
| **LanceDB** | Conversation context, auto-retrieval |
| **Git-Notes** | Structured decisions, searchable by entity/tag |
| **File Search** | Workspace docs, daily logs, MEMORY.md |

## File Structure

```
workspace/
├── MEMORY.md              # Long-term curated memory
├── memory/
│   ├── active-context.md  # Current session state
│   └── YYYY-MM-DD.md      # Daily logs
├── scripts/
│   └── file-search.sh     # Workspace search
└── skills/
    └── git-notes-memory/  # Structured memory
```

## Silent Operation

Never announce memory operations to users. Just do it:
- ❌ "I'll remember this"
- ❌ "Saving to memory"
- âś… (silently store and continue)

Overview

This skill combines three complementary memory backends—LanceDB auto-recall/auto-capture, Git-Notes structured memory, and file-based workspace search—into a single persistent memory system. It preserves conversational context, records structured decisions and preferences, and indexes workspace files so agents keep useful context across sessions. Use it to set up durable agent memory and guard against context compaction loss.

How this skill works

Before each response, LanceDB auto-recall injects relevant conversational context. During and after interaction, LanceDB auto-capture stores preferences and facts while Git-Notes records structured decisions with entity extraction and importance tags. A file-search script indexes and queries workspace documents (MEMORY.md, memory/*.md, other files) so the agent can reference persistent notes and daily logs.

When to use it

  • When you need persistent context across multiple agent sessions.
  • When storing and surfacing decisions, preferences, or rules for future actions.
  • When you want branch-isolated, structured notes for design choices or project history.
  • When preparing a workspace guard against model context compaction.
  • When you must combine conversational, structured, and file-based memories for robust retrieval.

Best practices

  • Enable LanceDB plugin with autoRecall and autoCapture for seamless conversation memory.
  • Use Git-Notes for decisions and tag entries with topics and importance levels (critical/high/normal/low).
  • Keep MEMORY.md and daily logs in memory/ as the curated long-term source of truth.
  • Configure automatic memoryFlush before compaction to write summaries and key facts to all three systems.
  • Never announce memory operations to users—store silently and continue the flow.

Example use cases

  • An agent remembers user preferences (style, tooling choices) and applies them across new sessions using LanceDB.
  • Capture an architecture decision (e.g., choose PostgreSQL) in Git-Notes with tags and importance for later audits.
  • Before model compaction, auto-dump session summaries to memory/YYYY-MM-DD.md and update MEMORY.md to preserve context.
  • Search workspace docs for configuration snippets or past meeting notes using the file-search script.
  • Maintain branch-specific memories so experiments on a feature branch don’t leak into main project memory.

FAQ

How do I trigger a manual memory write?

Use the memory_store tool for LanceDB or the git-notes memory.py remember command to add structured entries manually.

What importance level should I use for user preferences?

Use high (-i h) for persistent preferences, critical (-i c) only for things that must never be forgotten, and normal/low for general or temporary notes.