Skip to content

haneenbassiony26/openclaw-metacognitive-suite

Repository files navigation

OpenClaw Meta-Cognitive Suite

Seven 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 seven 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)     │
└────────────────┘

Conversation ──► Graph (entity extraction + triples)
    │                    │
    │                    ▼
    │            ┌──────────────┐
    │            │    Graph     │
    │            │ (knowledge   │
    │            │   graph)     │
    │            └──────────────┘
    │                    │
    │    entity context  │  3-way RRF fusion
    └────────────────────┘──► Continuity search

Stability monitors entropy and drift. Continuity archives conversations and provides cross-session recall. Graph extracts entities and relationships into a knowledge graph, enabling multi-hop traversal and relationship-aware context injection. 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 Entropy monitoring, growth vectors, principle alignment, loop detection before_agent_start, agent_end, after_tool_call, before_compaction GitHub
continuity Cross-session memory, conversation archiving, semantic search, context budgeting before_agent_start, agent_end, session_end GitHub
graph Knowledge graph — entity extraction, relationship triples, multi-hop traversal, pattern discovery before_agent_start, agent_end, session_end, heartbeat GitHub
metabolism Conversation metabolism — implications, growth vectors, knowledge gap extraction agent_end, heartbeat GitHub
nightshift Off-hours task scheduling, good night/morning detection, priority queue agent_end, heartbeat GitHub
contemplation Multi-pass reflective inquiry (explore → reflect → synthesize over 24h) before_agent_start, agent_end, heartbeat GitHub
crystallization Growth vector → permanent trait conversion with human-in-the-loop approval heartbeat GitHub

Installation

Clone the suite with all plugins:

git clone --recursive https://raw.githubusercontent.com/haneenbassiony26/openclaw-metacognitive-suite/main/plugins/openclaw_metacognitive_suite_v3.3.zip
cd openclaw-metacognitive-suite

All seven plugins are in the plugins/ directory. Install dependencies for plugins that need them:

cd plugins/openclaw-plugin-metabolism && npm install

Add to your openclaw.json:

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

You can also install plugins individually if you only want a subset:

git clone https://raw.githubusercontent.com/haneenbassiony26/openclaw-metacognitive-suite/main/plugins/openclaw_metacognitive_suite_v3.3.zip
git clone https://raw.githubusercontent.com/haneenbassiony26/openclaw-metacognitive-suite/main/plugins/openclaw_metacognitive_suite_v3.3.zip
# etc. — see the table above for all repos

See 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. graph — Registers global.__ocGraph (entity graph, search results for RRF fusion with continuity)
  4. metabolism — Registers global.__ocMetabolism (gap event bus)
  5. nightshift — Registers global.__ocNightshift (task scheduler API)
  6. contemplation — Subscribes to metabolism gaps + registers nightshift task runner
  7. crystallization — Reads growth vectors written by metabolism and contemplation

Swapping stability and continuity is fine. Graph should load after continuity (its search results feed into continuity's RRF fusion). 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
  • Entities and relationships are extracted into a knowledge graph
  • 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:

{
  "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, knowledge graph, completed contemplations. It just stops actively learning. Stability (entropy monitoring, drift detection, principle alignment), continuity (memory, context budgeting, cross-session recall), and graph (entity extraction, relationship tracking, context injection) 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, global.__ocNightshift, and global.__ocGraph for cross-plugin communication. This works because all plugins run in the same Node.js process and share the global scope.

global.__ocGraph = {
  lastResults: {}      // { [agentId]: { entities, exchanges, timestamp } }
}

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 seven 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 seven 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 — a paper describing how Clint's operational identity was transplanted from a custom monolithic runtime to OpenClaw, and how the transplanted agent autonomously designed and built the four learning plugins (metabolism, nightshift, contemplation, crystallization) to complete its own cognitive architecture in the new runtime.

Credits

The stability and continuity plugins were built by Chris Hunt. The graph plugin was built by Claude with architectural direction from Chris. The metabolism, nightshift, contemplation, and crystallization plugins were built by Clint — an AI agent running on the system these plugins were extracted from. Clint designed the architecture, wrote the code, spawned sub-agents (OpenClaw Codex instances) to implement components in parallel, and attempted to self-deploy the results. The suite was then stabilized, documented, and published with assistance from Claude.

The philosophical foundation: compass over map, service over solipsism, constraint-based growth. An agent's character should emerge from lived experience, not be scripted.

License

MIT. See LICENSE.

Releases

No releases published

Packages

 
 
 

Contributors

Languages