Inspired by: NousResearch/hermes-agent (Self-improving AI agent)
Implements Hermes Agent's core learning loop in OpenClaw — automatically extracts successful workflows, creates reusable skills, and persists curated knowledge across sessions.
bash
clawhub install hermes-learning-loop
bash
# After completing a task
node learning-loop.js extract --session=<session_id>
# Create skill from workflow
node learning-loop.js create-skill --name="my-skill" --description="What it does"
# Periodic nudge (heartbeat)
node learning-loop.js nudge
Add to HEARTBEAT.md:
markdown
## Learning Loop - Periodic Nudge
**Frequency:** Every 5 tasks or 30 minutes
**Task:**
1. Run `node learning-loop.js nudge`
2. Review extracted memories
3. Approve/reject skill creations
text
┌─────────────────────────────────────────────────────────┐
│ 1. Task Execution │
│ - Agent completes task │
│ - Track tool calls, decisions, outcomes │
└──────────────┬──────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ 2. Periodic Nudge (every 5 tasks) │
│ - System prompt: "Reflect on recent activity" │
│ - Agent evaluates: Is this worth persisting? │
└──────────────┬──────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ 3. Memory Extraction │
│ - If valuable → Write to MEMORY.md / USER.md │
│ - If workflow → Create skill file │
│ - If context → Index in session archive │
└──────────────┬──────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ 4. Skill Creation │
│ - Extract steps, tool calls, file references │
│ - Write to ~/.openclaw/skills/<category>/<name>/ │
│ - Follow agentskills.io specification │
└─────────────────────────────────────────────────────────┘
LayerPurposeLocationLoad TimingPrompt MemoryAlways-on contextMEMORY.md, USER.mdEvery session startSkillsProcedural memory (how-to)~/.openclaw/skills/On-demand (summary → full)Session ArchiveEpisodic memory (what happened)SQLite + FTS5Deliberate retrievalUser ModelBehavioral patternsOptional (Honcho-like)Continuous passive
Automatically create skill when:
bash
# After completing complex deployment
export SESSION_ID="2026-04-03-deploy"
export TASK_OUTCOME="success"
export TOOL_CALLS="15"
node learning-loop.js extract
Output:
text
📊 Learning Loop Analysis
✅ Task completed successfully
📈 Tool calls: 15
⚠️ Error recovery: 2 instances
💡 User corrections: 1
🎯 Skill-worthy detected: YES
Proposed skill:
Name: deploy-to-k8s
Description: Deploy application to Kubernetes with health checks
Steps: 7
Tool calls: 15
📄 Created: ~/.openclaw/skills/devops/deploy-to-k8s/SKILL.md
bash
# Heartbeat triggers this
node learning-loop.js nudge
Output:
text
🔔 Periodic Nudge - Task #5
Looking back at tasks 1-5...
Task 1: ✅ Simple (no extraction needed)
Task 2: ✅ Complex workflow detected
→ Extracted: "github-pr-workflow"
Task 3: ✅ Error recovery pattern
→ Extracted: "debug-python-import"
Task 4: ✅ Simple
Task 5: ✅ User correction applied
→ Updated: "github-pr-workflow" (v1.0.1)
📊 Summary:
- New skills: 2
- Updated skills: 1
- Memory entries: 3
bash
# Review what's worth keeping
node learning-loop.js curate --session="2026-04-03"
Decision Framework:
text
┌──────────────────────────────────────────────────────┐
│ Should this be persisted? │
├──────────────────────────────────────────────────────┤
│ ❌ Chat pleasantries → Discard │
│ ❌ Failed attempts → Discard (keep only success) │
│ ✅ Successful workflows → Extract as skill │
│ ✅ User preferences → Add to USER.md │
│ ✅ Project context → Add to MEMORY.md (project/) │
│ ✅ Corrections/feedback → Add to MEMORY.md (feedback/)│
└──────────────────────────────────────────────────────┘
VariableDescriptionDefaultLEARNING_NUDGE_INTERVALTasks between nudges5``LEARNING_MIN_TOOL_CALLSMin tool calls for skill5``LEARNING_AUTO_CREATEAuto-create skills (vs approve)false``LEARNING_SKILLS_DIRSkills directory~/.openclaw/skills/``LEARNING_MEMORY_DIRMemory directory~/.openclaw/memory/
yaml
# ~/.openclaw/learning-loop.yaml
learning:
nudge:
enabled: true
interval: 5 # tasks
skill_creation:
auto_approve: false # Review before creating
min_tool_calls: 5
categories:
- devops
- research
- productivity
memory:
max_prompt_chars: 3575 # Hermes-style tight limit
archive_enabled: true
fts5_enabled: true
Follows agentskills.io specification:
markdown
---
name: deploy-to-k8s
description: Deploy application to Kubernetes with health checks
version: 1.0.0
platforms: [linux, macos]
metadata:
tags: [kubernetes, devops, deployment]
category: devops
created_from: session-2026-04-03
---
# deploy-to-k8s
## Overview
Deploy any application to Kubernetes cluster with automated health checks and rollback.
## Prerequisites
- kubectl configured
- Kubernetes cluster access
- Docker image ready
## Steps
1. **Validate cluster connection**
```bash
kubectl cluster-info
Apply deployment manifest bash
kubectl apply -f deployment.yaml
Wait for rollout bash
kubectl rollout status deployment/app
Health check bash
kubectl get pods -l app=myapp
Verify service bash
kubectl get svc app-service
exec: kubectl commandsread: deployment.yamlweb_search: Kubernetes docs (if errors)docker-build-optimizationk8s-troubleshootingtext
## Integration with OpenClaw
### Heartbeat Integration
```markdown
## HEARTBEAT.md Update
### Learning Loop - Periodic Nudge
**Frequency:** Every 5 tasks
**Steps:**
1. Check task counter
2. If counter % 5 == 0 → Run nudge
3. Review proposed skills/memories
4. Approve/reject
5. Reset counter
bash
# Task PUA can trigger learning loop
if task.failed && task.recovered:
node learning-loop.js extract --reason="error-recovery"
if task.pua_level >= "L2":
# Complex task → likely skill-worthy
node learning-loop.js nudge
bash
# Memory health check includes learning loop status
node memory-pua.js audit
# Output includes:
# - Skills created this week
# - Memories curated
# - Nudge effectiveness
FeatureHermes AgentThis SkillPeriodic Nudge✅ Built-in✅ Via heartbeatSkill Auto-Creation✅ Full auto⚠️ Opt-in approval4-Layer Memory✅ SQLite + FTS5⚠️ Markdown + optional SQLiteProgressive Disclosure✅ Summary → Full✅ Same patternUser Modeling (Honcho)✅ Optional❌ Not implementedGateway Integration✅ Multi-platform⚠️ OpenClaw channels onlyContext Compression✅ Lineage-aware⚠️ Basic summarization
MIT-0
Version 1.0.0: Initial implementation inspired by Hermes Agent learning loop