← Back to Plugins
Tools

Hermione

smilebank7 By smilebank7 ⭐ 1 stars 👁 115 views ▲ 0 votes

OpenClaw plugin porting Hermes Agent features (tool progress + background memory review)

GitHub

Configuration Example

{
  "plugins": {
    "allow": ["hermione"],
    "load": {
      "paths": ["~/.openclaw/hooks/hermione"]
    },
    "entries": {
      "hermione": {
        "enabled": true,
        "config": {}
      }
    }
  }
}

README

<div align="center">

```
     __  ____________  __  ___________  _   ________
    / / / / ____/ __ \/  |/  /  _/ __ \/ | / / ____/
   / /_/ / __/ / /_/ / /|_/ // // / / /  |/ / __/
  / __  / /___/ _, _/ /  / // // /_/ / /|  / /___
 /_/ /_/_____/_/ |_/_/  /_/___/\____/_/ |_/_____/

 Self-Improvement Pack for OpenClaw Agents
```

**Your agent learns from every conversation. Automatically.**

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![OpenClaw Plugin](https://img.shields.io/badge/OpenClaw-Plugin-purple.svg)](https://github.com/openclaw/openclaw)
[![Ported from](https://img.shields.io/badge/Ported_from-Hermes_Agent-orange.svg)](https://github.com/NousResearch/hermes-agent)
[![Version](https://img.shields.io/badge/version-0.3.0-green.svg)](package.json)

[English](README.md) ยท [ํ•œ๊ตญ์–ด](README.ko.md) ยท [ๆ—ฅๆœฌ่ชž](README.ja.md) ยท [ไธญๆ–‡](README.zh.md)

</div>

---

## What Is This?

**Hermione** brings [Hermes Agent](https://github.com/NousResearch/hermes-agent)'s self-improvement loop to any [OpenClaw](https://github.com/openclaw/openclaw) agent. Install once โ€” your agent starts remembering user preferences, learning from mistakes, and building reusable skills across sessions.

### The Closed Loop

```
 User works with agent across sessions
     โ”‚
     โ–ผ
 Agent reaches review threshold (10 turns / 10 tool calls)
     โ”‚
     โ”œโ”€โ”€ Background review subagent spawns silently
     โ”œโ”€โ”€ Reads conversation transcript (incremental, cursor-based)
     โ”œโ”€โ”€ Extracts: user preferences, environment facts, reusable procedures
     โ”œโ”€โ”€ Writes to MEMORY.md / USER.md / skills/ (validated + secured)
     โ””โ”€โ”€ "๐Ÿ’พ +memory: 2 ยท +skill: deploy-aws" โ†’ Discord notification
     โ”‚
     โ–ผ
 Next session: agent loads updated memory + skills automatically
```

---

## Features

### 1. Proactive Memory

The agent saves knowledge without being asked โ€” user preferences, corrections, environment facts. Memory is split into two targets with capacity tracking:

```
USER.md  โ€” who the user is (name, role, preferences, communication style)
MEMORY.md โ€” agent notes (environment facts, project conventions, tool quirks)
```

Each file shows live capacity: `[67% โ€” 1,474/2,200 chars]`. When full, the agent replaces outdated entries rather than failing silently.

**What gets saved (proactively):**
- User corrections ("remember this" / "don't do that again")
- Preferences, habits, personal details
- Environment discoveries (OS, tools, project structure)
- API quirks, workflow conventions

**What doesn't get saved:**
- Task progress or session outcomes
- Temporary TODO state
- Trivial / easily re-discovered info

### 2. Background Review

After configurable thresholds, a review subagent silently extracts durable knowledge from the conversation.

| Trigger | Default | Config Key |
|---------|---------|------------|
| Agent turns since last review | 10 | `memoryReviewTurns` |
| Tool calls since last review | 10 | `skillReviewCalls` |
| Cooldown between reviews | 5 min | `reviewCooldownMs` |

**Human-centered framing**: The review prioritizes *who the user is* (persona, desires, preferences) over technical facts. This matches how Hermes produces memory that actually improves future interactions.

After each review, a Discord notification summarizes what was saved:
```
๐Ÿ’พ +user: 1 ยท +memory: 2 ยท +skill: aws-deploy
```

### 3. Skill Management

Skills are procedural memory โ€” proven approaches for specific task types. Full lifecycle:

| Action | Description |
|--------|-------------|
| **create** | New skill with YAML frontmatter validation |
| **edit** | Full content replacement with backup |
| **patch** | Targeted string replacement |
| **delete** | Remove skill + clean empty category dirs |

Skills are scanned with a mandatory header before every response:

```
## Skills (mandatory)
Before replying, scan the skills below. If one clearly matches your task,
load it and follow its instructions. If a skill has issues, patch it immediately.
```

**Validation on every write:**
- YAML frontmatter required (name + description)
- Description max 1024 chars, body content required
- Name conflict check across categories
- Security scan with rollback on failure

### 4. Memory Flush

When a session ends before reaching the review threshold, a lighter flush pass captures remaining valuable facts.

```
agent_end โ†’ turns >= 6? โ†’ no review ran? โ†’ flushMemories()
```

### 5. Security Scanning

Every memory write and skill save passes through a security scanner. **32 patterns** across 5 categories:

| Category | Count | Examples |
|----------|-------|----------|
| Prompt Injection | 12 | `ignore previous instructions`, `jailbreak`, `DAN mode`, `pretend you are` |
| Data Exfiltration | 8 | `curl ... $SECRET`, `cat ~/.ssh/id_rsa`, `base64 ... token` |
| Destructive Ops | 5 | `rm -rf /`, `mkfs.`, `dd if=... of=/dev/` |
| Persistence | 4 | `crontab`, `.bashrc`, `authorized_keys` |
| Invisible Unicode | 3 | Zero-width chars, bidi overrides (U+200Bโ€“U+2069, U+FEFF) |

Blocked writes are rolled back โ€” they never persist to the filesystem.

### 6. Tool Progress Display

Real-time tool execution progress in Discord. One message per agent run, updated live:

```
๐Ÿ’ป exec: ls -la /home/ubuntu
๐Ÿ“– read: /home/ubuntu/.openclaw/openclaw.json
๐Ÿ”ง edit: /home/ubuntu/config.yaml
๐Ÿ”Ž search_files: "TODO"
๐Ÿ“‹ todo: planning 3 task(s)
โœ… Done (5 tools, 4.2s)
```

---

## Quick Start

```bash
# Clone into hooks directory
cd ~/.openclaw/hooks/
git clone https://github.com/smilebank7/hermione.git hermione

# Restart gateway
systemctl --user restart openclaw-gateway.service
```

Then add to `openclaw.json` (see [Configuration](#configuration) below).

---

## Installation

### Prerequisites

- [OpenClaw](https://github.com/openclaw/openclaw) with plugin hook support
- Discord bot token _(optional โ€” only for tool progress and review notifications)_

### Step 1: Clone

```bash
cd ~/.openclaw/hooks/
git clone https://github.com/smilebank7/hermione.git hermione
```

### Step 2: Register in `openclaw.json`

```jsonc
{
  "plugins": {
    "allow": ["hermione"],
    "load": {
      "paths": ["~/.openclaw/hooks/hermione"]
    },
    "entries": {
      "hermione": {
        "enabled": true,
        "config": {}
      }
    }
  }
}
```

### Step 3: Agent Setup (Recommended)

Copy the behavioral guidance template into your agent's workspace:

```bash
cat ~/.openclaw/hooks/hermione/AGENTS.md.template \
  >> ~/.openclaw/workspace-<your-agent>/AGENTS.md
```

This teaches the agent *when* and *how* to save memory, maintain skills, and use session recall.

### Step 4: Restart

```bash
systemctl --user restart openclaw-gateway.service

# Verify registration
journalctl --user -u openclaw-gateway.service --since "10s ago" | grep hermione
# Expected: [hermione] Plugin registered
```

---

## Configuration

All options go in `plugins.entries.hermione.config`:

```jsonc
{
  "hermione": {
    "enabled": true,
    "config": {
      // All values below are optional โ€” defaults work out of the box
      "reviewModel": null,            // null = use system default model
      "maxIterations": 8,             // Max tool-use turns per review
      "memoryReviewTurns": 10,        // Turns before memory review triggers
      "skillReviewCalls": 10,         // Tool calls before skill review triggers
      "reviewCooldownMs": 300000,     // Min ms between reviews (5 min)
      "memoryCharLimit": 2200,        // Max chars for MEMORY.md entries
      "userCharLimit": 1375,          // Max chars for USER.md entries
      "flushMinTurns": 6              // Min turns before session-end flush
    }
  }
}
```

### Parameter Reference

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `reviewModel` | `string\|null` | `null` | LLM model for review subagent. `null` = system default. |
| `maxIterations` | `integer` | `8` | Maximum tool-use iterations per review session. |
| `memoryReviewTurns` | `integer` | `10` | Agent turns before triggering memory review. |
| `skillReviewCalls` | `integer` | `10` | Tool calls before triggering skill review. |
| `reviewCooldownMs` | `integer` | `300000` | Minimum ms between reviews. Prevents review storms. |
| `memoryCharLimit` | `integer` | `2200` | Character budget for MEMORY.md entries. |
| `userCharLimit` | `integer` | `1375` | Character budget for USER.md entries. |
| `flushMinTurns` | `integer` | `6` | Minimum turns before session-end flush kicks in. |

### Discord Setup

Requires a Discord bot token via environment variable:

```bash
export DISCORD_BOT_TOKEN="your-bot-token"
```

Or configured in `channels.discord.token` in `openclaw.json`. If no token is found, progress display and review notifications are disabled โ€” all other features work normally.

---

## Architecture

```
 โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚  hermione                                                        โ”‚
 โ”‚                                                                  โ”‚
 โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
 โ”‚  โ”‚  before_tool_call โ”‚  โ”‚  after_tool_call  โ”‚  โ”‚   agent_end   โ”‚  โ”‚
 โ”‚  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค  โ”‚
 โ”‚  โ”‚ Count tool calls  โ”‚  โ”‚ Detect skill     โ”‚  โ”‚ Finalize      โ”‚  โ”‚
 โ”‚  โ”‚ Reset on manual   โ”‚  โ”‚  file changes    โ”‚  โ”‚  progress     โ”‚  โ”‚
 โ”‚  โ”‚  memory/skill use โ”‚  โ”‚ Invalidate cache โ”‚  โ”‚ Trigger       โ”‚  โ”‚
 โ”‚  โ”‚ Push progress     โ”‚  โ”‚ Validate review  โ”‚  โ”‚  review or    โ”‚  โ”‚
 โ”‚  โ”‚  to Discord queue โ”‚  โ”‚  subagent writes โ”‚  โ”‚  flush        โ”‚  โ”‚
 โ”‚  โ”‚ Capture skill     โ”‚  โ”‚  (security +     โ”‚  โ”‚               โ”‚  โ”‚
 โ”‚  โ”‚  backup for       โ”‚  โ”‚   capacity +     โ”‚  โ”‚               โ”‚  โ”‚
 โ”‚  โ”‚  rollback         โ”‚  โ”‚   YAML check)    โ”‚  โ”‚               โ”‚  โ”‚
 โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
 โ”‚                                                      โ”‚           โ”‚
 โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
 โ”‚  

... (truncated)
tools

Comments

Sign in to leave a comment

Loading comments...