← Back to Plugins
Voice

Memory Extract

5p00kyy By 5p00kyy 👁 10 views ▲ 0 votes

OpenClaw plugin: Per-turn memory extraction - automatically captures durable facts from conversation turns

GitHub

Configuration Example

{
  "plugins": {
    "entries": {
      "memory-extract": {
        "enabled": true,
        "config": {
          "minExtractLength": 200,
          "dedupeWindowMinutes": 30,
          "skipHeartbeats": true,
          "skipCrons": true
        }
      }
    }
  }
}

README

# openclaw-memory-extract

Per-turn memory extraction plugin for [OpenClaw](https://github.com/openclaw/openclaw).

Automatically extracts durable facts from every conversation turn and appends them to daily notes. Inspired by Claude Code's per-turn memory extraction pattern, implemented as a lightweight plugin with zero LLM calls.

## What it extracts

| Category | Examples |
|----------|----------|
| **Decisions** | "decided to use Sonnet", "the plan is to migrate", "agreed to keep the cron" |
| **Corrections** | "I was wrong about the port", "actually it's running on GPU 0" |
| **Infrastructure** | "now running on port 8080", "restarted the gateway" |
| **Config changes** | "enabled dreaming mode", "set heartbeat to 60min" |
| **Assignments** | "TODO: fix the auth profile", "waiting on user approval" |
| **State changes** | "installed the plugin", "created the repo", "deleted the old config" |

## How it works

1. Hooks `llm_output` — fires after every model response
2. Pattern-matches the assistant's text for durable facts
3. Deduplicates against recent extractions (configurable window)
4. Appends to `memory/daily/YYYY-MM-DD.md` with timestamps and categories

No LLM calls. Pure regex extraction. Runs in milliseconds per turn.

## Install

Copy to your OpenClaw extensions directory:

```bash
cp -r openclaw-memory-extract ~/.openclaw/extensions/memory-extract
```

Add to `openclaw.json`:

```json
{
  "plugins": {
    "entries": {
      "memory-extract": {
        "enabled": true,
        "config": {
          "minExtractLength": 200,
          "dedupeWindowMinutes": 30,
          "skipHeartbeats": true,
          "skipCrons": true
        }
      }
    }
  }
}
```

Restart your gateway.

## Configuration

| Option | Default | Description |
|--------|---------|-------------|
| `enabled` | `true` | Enable/disable the plugin |
| `minExtractLength` | `200` | Minimum response length (chars) to trigger extraction |
| `dedupeWindowMinutes` | `30` | Don't re-extract the same fact within this window |
| `skipHeartbeats` | `true` | Skip extraction on heartbeat triggers |
| `skipCrons` | `true` | Skip extraction on cron triggers |
| `workspaceDir` | auto | Override workspace directory |

## Output format

Facts are appended to daily notes like:

```markdown
### Auto-extracted [14:32]
- **Decision:** use Sonnet as primary model via API at ~$53/month
- **Config change:** enabled dreaming mode in memory-core plugin
- **Infrastructure:** gateway restarted, now running on pid 411617
```

## Design principles

- **No LLM calls** — pattern matching only, zero cost
- **Deduplication** — same fact won't be written twice within the configured window
- **Noise filtering** — skips heartbeats, crons, and short responses
- **Append-only** — never modifies existing daily note content
- **Fail-safe** — errors are logged, never crash the gateway

## Background

Claude Code uses "forked agents" (background agents sharing the parent's prompt cache) to extract durable facts after every turn. Since OpenClaw doesn't support forked agents, this plugin approximates the same behavior using the `llm_output` hook with pattern matching instead of LLM inference.

The tradeoff: we catch fewer subtle facts than an LLM would, but we run in milliseconds at zero cost and never fail. A future version could optionally fire a cheap local model call for deeper extraction.

## License

MIT
voice

Comments

Sign in to leave a comment

Loading comments...