← Back to Plugins
Tools

Metacognitive Suite

CoderofTheWest By CoderofTheWest 👁 180 views ▲ 0 votes

Meta-cognitive plugin suite for OpenClaw โ€” six composable plugins that give AI agents stability, memory, learning, scheduling, contemplation, and character growth

GitHub

Install

npm install
```

Configuration Example

{
  "plugins": {
    "load": {
      "paths": [
        "/path/to/openclaw-plugin-stability",
        "/path/to/openclaw-plugin-continuity",
        "/path/to/openclaw-plugin-metabolism",
        "/path/to/openclaw-plugin-nightshift",
        "/path/to/openclaw-plugin-contemplation",
        "/path/to/openclaw-plugin-crystallization"
      ]
    }
  }
}

README

# OpenClaw Meta-Cognitive Suite

**Six composable plugins that give OpenClaw agents the ability to learn, remember, reflect, and grow.**

This is the documentation and coordination repo for a suite of OpenClaw plugins that, together, implement a complete autonomous learning loop for AI agents. Each plugin handles one responsibility. They communicate through a lightweight global bus and compose through OpenClaw's hook lifecycle. You can install all six for full autonomy, or pick the subset that fits your use case.

## The Learning Loop

```
Conversation
    โ”‚
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     entropy, drift     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Stability โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  Continuity  โ”‚
โ”‚ (monitor) โ”‚     context, recall   โ”‚   (memory)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚                                     โ”‚
    โ”‚ entropy score                       โ”‚ archived exchanges
    โ–ผ                                     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   knowledge gaps   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Metabolism   โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ Contemplation โ”‚
โ”‚ (fast/slow)  โ”‚   growth vectors   โ”‚  (3-pass, 24h)โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚                                     โ”‚
    โ”‚ growth vectors                      โ”‚ growth vectors
    โ–ผ                                     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   schedules tasks  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Nightshift  โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚    (queued)    โ”‚
โ”‚ (scheduler)  โ”‚                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”‚
    โ”‚ 30+ days, validated
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Crystallization โ”‚
โ”‚ (permanent      โ”‚
โ”‚  character)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

**Stability** monitors entropy and drift. **Continuity** archives conversations and provides cross-session recall. **Metabolism** watches for significant moments and extracts implications through LLM processing. **Nightshift** schedules heavy work for when the user is away. **Contemplation** takes unresolved questions through three reflection passes over 24 hours. **Crystallization** converts long-standing growth vectors into permanent character traits with human approval.

## The Plugins

| Plugin | What It Does | Hooks | Repo |
|--------|-------------|-------|------|
| [stability](https://github.com/CoderofTheWest/openclaw-plugin-stability) | Entropy monitoring, growth vectors, principle alignment, loop detection | `before_agent_start`, `agent_end`, `after_tool_call`, `before_compaction` | [GitHub](https://github.com/CoderofTheWest/openclaw-plugin-stability) |
| [continuity](https://github.com/CoderofTheWest/openclaw-plugin-continuity) | Cross-session memory, conversation archiving, semantic search, context budgeting | `before_agent_start`, `agent_end`, `session_end` | [GitHub](https://github.com/CoderofTheWest/openclaw-plugin-continuity) |
| [metabolism](https://github.com/CoderofTheWest/openclaw-plugin-metabolism) | Conversation metabolism โ€” implications, growth vectors, knowledge gap extraction | `agent_end`, `heartbeat` | [GitHub](https://github.com/CoderofTheWest/openclaw-plugin-metabolism) |
| [nightshift](https://github.com/CoderofTheWest/openclaw-plugin-nightshift) | Off-hours task scheduling, good night/morning detection, priority queue | `agent_end`, `heartbeat` | [GitHub](https://github.com/CoderofTheWest/openclaw-plugin-nightshift) |
| [contemplation](https://github.com/CoderofTheWest/openclaw-plugin-contemplation) | Multi-pass reflective inquiry (explore โ†’ reflect โ†’ synthesize over 24h) | `before_agent_start`, `agent_end`, `heartbeat` | [GitHub](https://github.com/CoderofTheWest/openclaw-plugin-contemplation) |
| [crystallization](https://github.com/CoderofTheWest/openclaw-plugin-crystallization) | Growth vector โ†’ permanent trait conversion with human-in-the-loop approval | `heartbeat` | [GitHub](https://github.com/CoderofTheWest/openclaw-plugin-crystallization) |

## Installation

Clone all six plugins and add their paths to your `openclaw.json`:

```bash
git clone https://github.com/CoderofTheWest/openclaw-plugin-stability.git
git clone https://github.com/CoderofTheWest/openclaw-plugin-continuity.git
git clone https://github.com/CoderofTheWest/openclaw-plugin-metabolism.git
git clone https://github.com/CoderofTheWest/openclaw-plugin-nightshift.git
git clone https://github.com/CoderofTheWest/openclaw-plugin-contemplation.git
git clone https://github.com/CoderofTheWest/openclaw-plugin-crystallization.git
```

Install dependencies for plugins that need them:

```bash
cd openclaw-plugin-metabolism && npm install
```

Add to your `openclaw.json`:

```json
{
  "plugins": {
    "load": {
      "paths": [
        "/path/to/openclaw-plugin-stability",
        "/path/to/openclaw-plugin-continuity",
        "/path/to/openclaw-plugin-metabolism",
        "/path/to/openclaw-plugin-nightshift",
        "/path/to/openclaw-plugin-contemplation",
        "/path/to/openclaw-plugin-crystallization"
      ]
    }
  }
}
```

See [`openclaw.example.json`](./openclaw.example.json) for a complete configuration example with all plugin settings.

## Load Order

The order in `plugins.load.paths` matters. The plugins use a global bus for cross-plugin communication, and the bus endpoints must be registered before subscribers connect.

**Required order:**
1. **stability** โ€” Registers `api.stability` (entropy, growth vectors)
2. **continuity** โ€” Registers `api.continuity` (archive, search)
3. **metabolism** โ€” Registers `global.__ocMetabolism` (gap event bus)
4. **nightshift** โ€” Registers `global.__ocNightshift` (task scheduler API)
5. **contemplation** โ€” Subscribes to metabolism gaps + registers nightshift task runner
6. **crystallization** โ€” Reads growth vectors written by metabolism and contemplation

Swapping stability and continuity is fine. The critical constraint is: metabolism before contemplation (so the gap bus exists when contemplation subscribes), and nightshift before contemplation (so the task runner API exists when contemplation registers).

## Deployment Modes

### Training Mode (all plugins active)

Every plugin is enabled. The agent learns autonomously:

- Conversations are archived and semantically indexed
- High-entropy moments trigger metabolism processing
- Knowledge gaps flow to contemplation for multi-pass reflection
- Growth vectors accumulate and receive feedback
- After 30+ days, validated vectors become permanent traits

This is the default. Use it during the period where you want the agent to develop its character.

### Production / Frozen Mode

Disable the four learning plugins by setting `"enabled": false` in each:

```json
{
  "plugins": {
    "entries": {
      "metabolism": { "enabled": false },
      "nightshift": { "enabled": false },
      "contemplation": { "enabled": false },
      "crystallization": { "enabled": false }
    }
  }
}
```

The agent retains everything it learned โ€” growth vectors, crystallized traits, conversation archives, completed contemplations. It just stops actively learning. **Stability** (entropy monitoring, drift detection, principle alignment) and **continuity** (memory, context budgeting, cross-session recall) stay active.

Use this when your agent's character is where you want it and you're deploying to production. The personality is frozen but the operational capabilities remain.

All four learning plugins check `if (!config.enabled) return` in their hook handlers. No code changes needed โ€” it's purely a configuration toggle.

## Inter-Plugin Communication

OpenClaw gives each plugin its own scoped `api` object. Properties set on one plugin's `api` are not visible to other plugins. This is by design โ€” it prevents namespace collisions.

The suite uses `global.__ocMetabolism` and `global.__ocNightshift` for cross-plugin communication. This works because all plugins run in the same Node.js process and share the global scope.

```
global.__ocMetabolism = {
  gapListeners: []     // Array of (gaps, agentId) => void callbacks
}

global.__ocNightshift = {
  registerTaskRunner,   // (name, handler) => void
  queueTask,           // (agentId, task) => void
  isInOfficeHours,     // (agentId) => boolean
  isUserActive,        // (agentId) => boolean
}
```

If OpenClaw adds native cross-plugin messaging in a future version, these can be migrated. The pattern is intentionally simple so migration is straightforward.

## Multi-Agent Support

All six plugins support multiple agents running on the same OpenClaw gateway. Each agent gets isolated state:

- **Data directories**: `data/` for the default agent, `data/agents/{agentId}/` for others
- **Workspace paths**: Each agent's growth vectors, traits, and insights resolve from its own workspace
- **Session isolation**: Conversation transcripts are per-session, but plugin memory (continuity archive, stability state) is per-agent โ€” crossing session boundaries by design
- **Hook context**: Every hook receives `ctx.agentId` which is used to look up the correct state

Agents can share the same plugin instances without interference.

## Training Dashboard

The `dashboard.html` file is a self-contained single-page application that connects to the OpenClaw gateway via WebSocket and visualizes the entire meta-cognitive pipeline.

Open it in any browser and enter your gateway token. No build step, no external dependencies.

**Sections:**
- **Pipeline Overview** โ€” Real-time status of all six plugins with active item counts
- **Contemplation Browser** โ€” Browse inquiries by topic tag, source, or status. Read full 3-pass outputs.
- **Growth Vectors** โ€” Track vector accumulation and feedback from stability
- **Metabolism Activity** โ€” Recent candidates, processing results, gap extraction
- **Agent Status** โ€” Entropy level, nightshift state, learning mode indicator

## Research Paper

The suite's origin story is documented in [Cross-Runtime Identity Transplant: Porting an Emergent LLM Agent Between Harnesses and Substrates](./clint-identity-transplant.md) โ€” a paper describing how Clint's operational identity was transplanted from a custom monolithic runtime to Ope

... (truncated)
tools

Comments

Sign in to leave a comment

Loading comments...