Part 12: Self-Improving System (Stop Making the Same Mistakes) banner
OnlyTerp OnlyTerp

Part 12: Self-Improving System (Stop Making the Same Mistakes)

Development community intermediate

Description

Your agent makes a mistake Monday. You correct it. Tuesday, same mistake. Wednesday, same mistake. Every session starts fresh — corrections evaporate. **The fix: a micro-learning loop that costs <100

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

Repository README

This is the README for OnlyTerp/openclaw-optimization-guide, shared by 11 entries in this directory. It describes the repository, not this entry specifically.

Part 12: Self-Improving System (Stop Making the Same Mistakes)

Your agent makes a mistake Monday. You correct it. Tuesday, same mistake. Wednesday, same mistake. Every session starts fresh — corrections evaporate.

**The fix: a micro-learning loop that costs <100 tokens/message and compounds forever.**

The Architecture

Every message:
  Did the user correct me?     → append to .learnings/corrections.md
  Did a command fail?          → append to .learnings/ERRORS.md
  Did I learn something new?   → append to .learnings/LEARNINGS.md

Every session start:
  Read .learnings/HOT.md       → follow active rules

Daily (cron, $0):
  Scan for 3+ repeated patterns → promote to HOT.md

Weekly (cron, $0):
  HOT entries used 30+ days    → promote to AGENTS.md/SOUL.md (permanent)
  HOT entries unused 30 days   → demote to archive

Why This Works

  • Week 1: 5 corrections logged. Agent still makes mistakes but they're recorded.
  • Week 2: Repeated patterns promoted to HOT.md. Agent reads HOT.md every session — stops making those specific mistakes.
  • Week 4: Best learnings promoted to AGENTS.md. They're now permanent rules, loaded every message. The agent is measurably smarter than week 1.
  • Week 8: 30+ corrections avoided automatically. System compounds.

Why Existing Approaches Fail

Most "self-improving" agent setups just dump full session summaries into a vector database. This naive approach fails because:

  • Problem 1: No filtering — every message, typo, and false start gets embedded, drowning real insights in noise. Signal-to-noise ratio collapses.
  • Problem 2: No promotion — a critical architecture fix from yesterday sits next to "lunch was good" in the same flat vector space. High-impact learnings never rise to prominence.
  • Problem 3: No decay — a correction from 3 months ago ("always run on r6g.2xlarge") persists even after infrastructure changes, actively poisoning decisions.

The micro-learning loop fixes this with:

  • Selective capture: Only log 4 events: user corrections, tool failures, discovered insights, stated preferences.
  • Tiered promotion: Entries flow from raw logs → HOT.md → AGENTS.md/SOUL.md → vault based on usage and impact.
  • Active decay: Unused entries automatically demote and eventually archive, keeping the active memory lean and current.

Setup

**Step 1: Create the learnings directory**

workspace/
  .learnings/
    HOT.md              # Active rules, loaded every session
    corrections.md      # User corrections log
    ERRORS.md           # Command/tool failure log
    LEARNINGS.md        # General insights
    FEATURE_REQUESTS.md # Ideas for improvement
    projects/           # Project-specific learnings
    domains/            # Domain-specific learnings
    archive/            # Demoted cold entries

**Step 2: Add the micro-learning loop to AGENTS.md**

### Micro-Learning Loop (EVERY MESSAGE — silent, <100 tokens)
After EVERY response, sile