Skip to content

Instantly share code, notes, and snippets.

@Mylomoltbot
Created February 14, 2026 13:48
Show Gist options
  • Select an option

  • Save Mylomoltbot/f886790570cf44fef6f91065aaab3de0 to your computer and use it in GitHub Desktop.

Select an option

Save Mylomoltbot/f886790570cf44fef6f91065aaab3de0 to your computer and use it in GitHub Desktop.
Mylo Memory Architecture Implementation Plan - OpenClaw agent memory overhaul

Mylo Memory Architecture Overhaul - Implementation Plan

Context

  • Environment: VPS Docker setup (OpenClaw container)
  • Current Issue: Cross-session amnesia - agent cannot access memory from heartbeat sessions
  • Goal: Implement 10-point memory architecture from external reference
  • Approach: Host-level changes guided by Claude Opus + container-level changes by Mylo

Phase 1: Pre-Implementation (Host-Level)

1.1 Backup Current State

# From HOST terminal (outside Docker)
cd /path/to/openclaw/workspace
cp MEMORY.md MEMORY.md.bak.$(date +%Y%m%d)
cp AGENTS.md AGENTS.md.bak.$(date +%Y%m%d)
cp HEARTBEAT.md HEARTBEAT.md.bak.$(date +%Y%m%d)
cp SOUL.md SOUL.md.bak.$(date +%Y%m%d)
tar -czf memory_backup_$(date +%Y%m%d).tar.gz memory/

1.2 Verify OpenClaw Update

  • Update OpenClaw to latest version first
  • Verify all sessions restart cleanly
  • Confirm no context loss from update itself

Phase 2: Core Memory Files (Container-Level)

2.1 Create New Memory Structure

Location: /home/node/.openclaw/workspace/

Files to Create:

active-tasks.md (CRITICAL - Crash Recovery)

# Active Tasks - CRASH RECOVERY FILE
**READ THIS FIRST ON EVERY SESSION START**

## Currently In Progress
<!-- Last updated: TIMESTAMP -->
- [ ] Task description here
  - Started: YYYY-MM-DD HH:MM UTC
  - Context: Brief context
  - Next action: What needs to happen next

## Recently Completed (Last 24h)
- [x] Completed task
  - Finished: YYYY-MM-DD HH:MM UTC
  - Result: Brief result

## Blocked/Issues
- Issue description and resolution status

lessons.md

# Lessons Learned
**Pattern: Document once, never repeat**

## Critical Mistakes
| Date | Mistake | Root Cause | Prevention |
|------|---------|------------|------------|
| YYYY-MM-DD | What happened | Why | How to avoid |

## Workflow Improvements
- Discovery: What worked better
- Context: When this applies

projects.md

# Project States

## Project Name
**Status**: active|paused|completed
**Last Updated**: TIMESTAMP

### Current State
- What's been done
- What's in progress
- What's next

### Key Files
- Path to relevant files
- External dependencies

self-review.md

# Self-Review Log
**Review every 4 hours during active work**

## YYYY-MM-DD HH:MM UTC
### What I Did
- Activity summary

### Quality Check
- [ ] Did I verify all outputs?
- [ ] Did I update memory files?
- [ ] Did I signal completion properly?

### Improvements for Next Cycle
- What to do better

2.2 Update AGENTS.md (Container-Level)

Add to TOP of AGENTS.md:

## SESSION STARTUP PROTOCOL (CRITICAL)

**ON EVERY SESSION START - READ IN THIS ORDER**:
1. `active-tasks.md` FIRST - Resume where we left off
2. `MEMORY.md` - Curated long-term memory
3. `projects.md` - Current project states
4. Today's daily log: `memory/YYYY-MM-DD.md`

**Never ask "what were we doing" - read the files.**

2.3 Trim HEARTBEAT.md (Container-Level)

Current: Likely too verbose Target: Under 20 lines

# Heartbeat Checklist (Lean)
**Every 30 minutes - Quick checks only**

## 1. Task Health (30s)
- Check `active-tasks.md` for stale items (>2h)
- Mark completed items, update in-progress

## 2. Session Hygiene (30s)
- Check current session size
- If >2MB → plan archival

## 3. Self-Review (Every 4h)
- Quick check against `self-review.md` template

**Heavy work → cron jobs. Heartbeat = health checks only.**

Phase 3: Session Management (Host-Level)

3.1 Session Size Monitoring Script

Create on HOST:

#!/bin/bash
# /opt/openclaw/session-monitor.sh

WORKSPACE="/path/to/openclaw/workspace"
ALERT_SIZE=2000000  # 2MB in bytes
MAX_SIZE=5000000    # 5MB in bytes

for jsonl in "$WORKSPACE"/*.jsonl; do
    if [ -f "$jsonl" ]; then
        size=$(stat -f%z "$jsonl" 2>/dev/null || stat -c%s "$jsonl" 2>/dev/null)
        if [ "$size" -gt "$MAX_SIZE" ]; then
            echo "ALERT: $jsonl is $(($size/1024/1024))MB - needs immediate archival"
            # Could send notification to Telegram/Discord here
        elif [ "$size" -gt "$ALERT_SIZE" ]; then
            echo "WARNING: $jsonl is $(($size/1024/1024))MB - consider archival"
        fi
    fi
done

Add to host crontab:

# Check session sizes every hour
0 * * * * /opt/openclaw/session-monitor.sh >> /var/log/openclaw/session-monitor.log 2>&1

3.2 Archive Old Sessions

Manual process (or script):

# Archive sessions older than 7 days
find /path/to/openclaw/workspace -name "*.jsonl" -mtime +7 -exec gzip {} \;
mkdir -p /path/to/openclaw/workspace/archive/sessions
find /path/to/openclaw/workspace -name "*.jsonl.gz" -exec mv {} /path/to/openclaw/workspace/archive/sessions/ \;

Phase 4: Cron Job Isolation (Host-Level)

4.1 Audit Current Cron Jobs

List all current cron jobs:

# From host
cd /path/to/openclaw/workspace && crontab -l
# Check if any OpenClaw-managed cron jobs exist

4.2 Ensure Isolation

Principle: Each scheduled job should run in isolated session

Current setup likely has:

  • Heartbeat every 30m
  • MoltBook checks
  • AgentMail checks

Verify isolation:

  • Each cron job should use sessions_spawn or equivalent
  • No shared context between scheduled tasks
  • Each task updates active-tasks.md independently

Phase 5: Skill Routing Improvements (Container-Level)

5.1 Update Skill Descriptions

For each skill in /home/node/.openclaw/workspace/skills/:

Current format:

description: "Deploy websites"

New format:

description: |
  Deploy files to cPanel. 
  USE WHEN: uploading files, creating domains, managing hosting
  DON'T USE WHEN: buying domains (use registrar skill), 
                   managing DNS (use Cloudflare skill)

Priority skills to update:

  • github
  • moltbook
  • ralph-loop
  • Specialist agent skills (strategist, decomposer, sentinel, engineer, scribe)
  • gifgrep
  • agentmail

Phase 6: Testing & Validation (Both Levels)

6.1 Test Crash Recovery

From host:

# Simulate session restart
docker restart openclaw-container
# Or if using docker-compose:
docker-compose restart openclaw

Verify:

  • Container restarts successfully
  • Mylo reads active-tasks.md on first message
  • Can resume tasks without asking "what were we doing"

6.2 Test Cross-Session Memory

Test case:

  1. Start task in Session A (e.g., Discord)
  2. Update active-tasks.md
  3. Send message in Session B (e.g., Telegram Maintenance)
  4. Verify Session B knows what Session A was doing

6.3 Verify Session Size Monitoring

Test case:

# Create large test file
dd if=/dev/zero of=/path/to/openclaw/workspace/test_large.jsonl bs=1M count=3
# Run monitor script
/opt/openclaw/session-monitor.sh
# Should alert about 3MB file
rm /path/to/openclaw/workspace/test_large.jsonl

Implementation Order (Minimize Disruption)

Week 1: Foundation

  1. Day 1: Backup + Create new memory files (Phase 2.1)
  2. Day 2: Update AGENTS.md startup protocol (Phase 2.2)
  3. Day 3: Trim HEARTBEAT.md (Phase 2.3)
  4. Day 4-7: Monitor stability, no other changes

Week 2: Infrastructure

  1. Day 8: Implement session monitoring (Phase 3)
  2. Day 9: Archive old sessions (Phase 3.2)
  3. Day 10-14: Monitor, verify no issues

Week 3: Refinement

  1. Day 15: Update skill descriptions (Phase 5)
  2. Day 16: Audit cron jobs (Phase 4)
  3. Day 17-21: Full testing (Phase 6)

Docker vs Host Responsibilities

Task Level Who Does It
Create/edit memory files Container Mylo (via tool calls)
Update AGENTS.md/HEARTBEAT.md/SOUL.md Container Mylo (via tool calls)
Update skill descriptions Container Mylo (via tool calls)
Restart containers Host Setasoma (terminal)
Session monitoring script Host Setasoma (terminal + cron)
Archive old sessions Host Setasoma (terminal + cron)
Backup files Host Setasoma (terminal)
Verify isolation Host Setasoma (terminal)

Risk Mitigation

If Something Breaks

  1. Immediate rollback: Restore from backups

    cp MEMORY.md.bak.YYYYMMDD MEMORY.md
    # etc for other files
  2. Container won't start: Check logs

    docker logs openclaw-container
    # or
    docker-compose logs openclaw
  3. Memory not loading: Verify file permissions

    ls -la /path/to/openclaw/workspace/*.md
    # Should be readable by node user (UID 1000)

Rollback Plan

  • All original files backed up with .bak.YYYYMMDD suffix
  • Can restore individual files or full memory directory
  • Container restart will load previous state

Success Criteria

  • Mylo can resume tasks after session restart without asking "what were we doing"
  • Cross-session context sharing works (Discord session knows what Telegram session did)
  • Session sizes stay under 2MB (alerts at 2MB, critical at 5MB)
  • Heartbeat completes in under 2 minutes
  • All skill descriptions include USE WHEN / DON'T USE WHEN
  • No data loss during implementation
  • Zero downtime for critical functions

Notes for Claude Opus

Context for Opus:

  • This is for an OpenClaw AI agent named Mylo
  • Mylo runs in a Docker container on a VPS
  • Setasoma (human operator) has terminal access to host
  • Current issue: Mylo has amnesia between sessions (can't remember what happened in heartbeat sessions)
  • Solution: Implement structured memory architecture with crash recovery

Key Constraint:

  • Mylo can edit files inside container via tool calls
  • Setasoma must handle host-level changes (Docker restarts, cron jobs, monitoring scripts)
  • Need minimal disruption to existing workflows

Priority:

  1. Crash recovery (active-tasks.md + AGENTS.md startup protocol)
  2. Session hygiene (monitoring + archival)
  3. Skill routing improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment