Skip to content

Ramsbaby/openclaw-memorybox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 OpenClaw MemoryBox

Install once. Forget about memory management forever.

Zero dependencies. Works alongside Mem0, Supermemory, QMD β€” or standalone.

CI Version OpenClaw Compatible License: MIT ShellCheck GitHub stars Last commit

⚑ Quick Start β€’ πŸ’» CLI β€’ πŸ“Š Results β€’ πŸ”§ How It Works β€’ ❓ FAQ


MemoryBox Demo

Full diagnostic in one command: health check β†’ size analysis β†’ duplicates β†’ stale content β†’ suggestions


⚑ Quick Start

Works in 3 commands. 30 seconds total.

Step 1: Install

git clone https://github.com/Ramsbaby/openclaw-memorybox.git
cd openclaw-memorybox && chmod +x bin/memorybox
sudo ln -sf "$(pwd)/bin/memorybox" /usr/local/bin/memorybox

Step 2: Diagnose

memorybox doctor ~/openclaw

You'll see:

  • βœ… What's healthy
  • ⚠️ What needs attention
  • 🚨 What's critical
  • πŸ“Œ Exactly how to fix it

Step 3: Fix (if needed)

memorybox split ~/openclaw    # Interactive: split large sections
memorybox archive ~/openclaw  # Move old logs to archive/

Next: See real results β€’ All commands β€’ Teach your agent


🎯 Before & After

Before MemoryBox

MEMORY.md: 20KB+ (bloated)
Context pressure: 98% (constantly compacting)
Gateway: Crashes from context overflow
Agent: Slow, unstable

After MemoryBox (5 minutes)

MEMORY.md: 3.5KB (lean)
Context pressure: 7% (comfortable)
Gateway: Stable 24/7
Agent: Fast, reliable

Bottom line: Your MEMORY.md drops 80%+, context stays healthy, agent stays fast.


🌟 The Problem

Your OpenClaw agent's MEMORY.md grows every day. At some point it hits 20KB+, gets loaded into every session, eats tokens, and eventually causes context overflow.

The crash chain:

Memory bloat β†’ Context overflow β†’ Compaction failure β†’ Gateway crash

MemoryBox prevents this in 5 minutes:

memorybox doctor ~/openclaw   # diagnose
memorybox split ~/openclaw    # fix interactively

Your MEMORY.md stays lean. Your agent stays fast. Move on to things that matter.

2026 context: Personal AI agents running 24/7 locally are surging β€” subscription fatigue is real, and "own your AI" is the new default. Memory management is now the #1 silent bottleneck. MemoryBox solves it before it crashes you.


πŸ”§ How It Works

MemoryBox applies a simple 3-tier pattern (inspired by Letta/MemGPT):

workspace/
β”œβ”€β”€ MEMORY.md              ← Tier 1: Core facts only (≀10KB, loaded everywhere)
└── memory/
    β”œβ”€β”€ YYYY-MM-DD.md      ← Tier 1.5: Daily logs (today+yesterday, auto-loaded)
    β”œβ”€β”€ domains/           ← Tier 2: Detailed reference (searched on-demand)
    β”‚   β”œβ”€β”€ persona.md
    β”‚   β”œβ”€β”€ decisions.md
    β”‚   └── ...
    β”œβ”€β”€ projects/          ← Tier 2: Per-project context
    └── archive/           ← Tier 3: Old daily logs (14+ days)
Tier Loaded when Token cost
Tier 1 Every session, automatically ~3.5KB (lean!)
Tier 2 On-demand via memory_search Only when needed
Tier 3 Manual reference only ~0

Key insight: OpenClaw's memory_search indexes memory/**/*.md recursively. Tier 2 files are automatically searchable β€” zero config changes.


πŸ“Š Real Results

Tested on a production instance (7 Discord channels, 48 crons, running 24/7):

Metric Before After Improvement
MEMORY.md size 20,542 bytes 3,460 bytes -83% πŸŽ‰
Context pressure 98% (critical) 7% (healthy) -91%
Compaction frequency Multiple per session Rare (~weekly) 10x fewer
Gateway crashes 2-3/week 0 100% stable βœ…
memory_search βœ… Works βœ… Still works No change
Setup time β€” 5 minutes One-time

Real Terminal Output

Before (Health Check):

$ memorybox health ~/openclaw
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ₯ Health Score: 28/100 🚨 CRITICAL

MEMORY.md: 20,542 bytes (205%) 🚨
Daily logs: 15 files (8 need archiving)
Duplicates: 12 potential matches
Stale: 3 files unchanged 60+ days

ACTION REQUIRED: Run 'memorybox doctor' for full diagnostic
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

After (5 minutes later):

$ memorybox health ~/openclaw
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ₯ Health Score: 92/100 βœ… EXCELLENT

MEMORY.md: 3,460 bytes (35%) βœ…
Daily logs: 7 active, 8 archived βœ…
Duplicates: 0 βœ…
Stale: 0 βœ…

All systems green. No action needed.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Honest note: The 83% reduction applies to MEMORY.md load β€” roughly 5-15% of total per-session tokens depending on conversation length. But in a 24/7 agent with 48 crons, those savings compound over thousands of sessions. More importantly, it prevents the context overflow that crashes your agent β€” and that's worth far more than the token savings alone.


πŸ’» CLI Commands

memorybox doctor [path]    # Full diagnostic β€” start here
memorybox analyze [path]   # Section-by-section size breakdown with bar charts
memorybox split [path]     # Interactive: move large sections to domain files
memorybox health [path]    # Quick health score (0-100)
memorybox archive [path]   # Move old daily logs (14+ days) to archive/
memorybox dedupe [path]    # Find duplicate content across files
memorybox stale [path]     # Detect outdated content
memorybox suggest [path]   # Improvement recommendations
memorybox report [path]    # Before/after token savings
memorybox init [path]      # Set up 3-tier directory structure

Most users only need two commands:

  1. memorybox doctor β€” see what's wrong
  2. memorybox split β€” fix it interactively

Options

memorybox -w ~/my-workspace doctor   # Custom workspace path
memorybox -d 7 archive               # Archive logs older than 7 days
memorybox -m 8000 health             # Custom max target (default: 10KB)

πŸ“¦ Installation

Option A: Quick Install (recommended)

git clone https://github.com/Ramsbaby/openclaw-memorybox.git
cd openclaw-memorybox && chmod +x bin/memorybox
sudo ln -sf "$(pwd)/bin/memorybox" /usr/local/bin/memorybox

Option B: Manual

# Download just the CLI script
curl -sSL https://raw.githubusercontent.com/Ramsbaby/openclaw-memorybox/main/bin/memorybox -o /usr/local/bin/memorybox
chmod +x /usr/local/bin/memorybox

Verify

memorybox --version   # memorybox v2.1.0
memorybox doctor ~/openclaw

πŸ₯ Example: Doctor Output

🩺 MemoryBox Doctor β€” Full Diagnostic
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Workspace: /Users/you/openclaw
2026-02-11 17:00:00

[1/5] Health Check

    βœ— MEMORY.md over limit: 20,542 bytes (205%) 🚨
    βœ“ domains/: 3 files
    β–³ 8 daily logs need archiving (>14 days)
    βœ“ memory/ root is clean
    βœ“ archive/ exists

    Health Score: 40/100 🚨 Critical

[2/5] Size Analysis

  MEMORY.md: 20,542 bytes (205%)
  domains/: 3,200 bytes
  Total managed: 23,742 bytes

[3/5] Duplicate Check

  ⚠️  2 potential duplicate lines

[4/5] Stale Content

  ⏰ 1 domain file(s) unchanged for 60+ days

[5/5] Suggestions

  πŸ“Œ 3 section(s) could be split to domains/
  πŸ—„οΈ  8 daily logs ready for archiving

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ”„ What This Is (and Isn't)

MemoryBox is a maintenance tool, like df for your agent's memory.

It doesn't replace your memory system β€” it keeps it healthy.

Tool What it does Category
Mem0 Decides what to remember 🧠 Memory engine
Supermemory Cloud-based persistent recall 🧠 Memory engine
QMD Local search backend πŸ” Search engine
MemoryBox Keeps files organized & lean 🧹 Maintenance tool

You can use MemoryBox with all of the above, or with none of them. It only touches file structure β€” never configs, never plugins, never internals.


πŸ“– Origin Story

I run an OpenClaw agent 24/7 β€” 7 Discord channels, 48 cron jobs. As it learned, MEMORY.md ballooned to 20KB+. Every session loaded all of it.

One day, context hit 100%. Compaction corrupted state. I tried to fix the config β€” and crashed the gateway.

That crash led to openclaw-self-healing (auto-recovery in ~30s). But the root cause was memory bloat. So I built MemoryBox to prevent it from happening again.

Memory bloat β†’ Context overflow β†’ Gateway crash
  β†’ Built self-healing (recover from crashes)
  β†’ Built MemoryBox (prevent the bloat)
  β†’ Problem solved at both ends.

πŸ€– Teach Your Agent the 3-Tier Pattern

Add to your AGENTS.md:

## Memory Protocol
- **MEMORY.md** (≀10KB): Core facts only. Loaded everywhere β€” keep it lean.
- **memory/domains/*.md**: Detailed reference. Use `memory_search` to find.
- **memory/archive/**: Old logs. Rarely needed.

When MEMORY.md grows past 8KB, split large sections to domains/.

Set It and Forget It (Optional Cron)

{
  "name": "Memory Maintenance",
  "schedule": { "kind": "cron", "expr": "0 23 * * 0", "tz": "Asia/Seoul" },
  "sessionTarget": "isolated",
  "payload": {
    "kind": "agentTurn",
    "message": "Run: memorybox archive && memorybox health. Report if score < 80."
  }
}

βœ… Compatibility

Works with everything:

Plugin / Backend Compatible Notes
memory-core (default) βœ… No changes needed
Mem0 βœ… Different layer β€” no conflict
Supermemory βœ… Different layer β€” no conflict
QMD βœ… Indexes same files
memory_search βœ… Indexes memory/**/*.md recursively
memory_get βœ… Reads any memory/ file

Does NOT touch:

  • openclaw.json β€” no config changes
  • Plugin behavior β€” no overrides
  • OpenClaw internals β€” files only

🀝 Companion Project

Layer Tool What It Does
Prevention MemoryBox Keeps memory lean β†’ no context overflow
Recovery Self-Healing 4-tier auto-recovery β†’ gateway back in ~30s

Both zero-dependency, both MIT licensed, both battle-tested on the same production instance.


❓ FAQ

Q: My MEMORY.md is only 5KB. Do I need this? A: Not yet. Bookmark it for when it grows. Or run memorybox health to confirm you're fine.

Q: Will this break my existing setup? A: No. It only creates directories and moves content you approve. Backup is automatic.

Q: Does memory_search find files in subdirectories? A: Yes. OpenClaw indexes memory/**/*.md recursively. Official docs confirm this.

Q: I'm using Mem0/Supermemory. Should I also use this? A: Yes β€” they solve different problems. Mem0 decides what to remember. MemoryBox keeps your file structure clean so sessions load fast.

Q: Will OpenClaw updates break this? A: Unlikely. This uses standard markdown files in the standard memory directory. OpenClaw's philosophy is "files are source of truth" β€” that won't change.


πŸ“Š Stats & Growth

Repository Metrics (2026-02-17)

Metric Total Unique Status
⭐ Stars 2 - Growing
🍴 Forks 2 - 2 days after launch!
πŸ‘€ Watchers 2 - -
πŸ‘οΈ Views 46 18 Early stage
πŸ“₯ Clones 319 145 Real adoption πŸ”₯

πŸ“Š Daily Traffic:

Date Views Unique Clones Unique
2/10 (Launch) 14 7 134 84
2/11 24 5 66 31
2/12 3 3 47 22
2/13 1 1 56 24
2/14 3 3 8 4
2/15 1 1 8 4
Total 46 18 319 145

Stats are updated automatically. Last update: 2026-02-17


🀝 Contributing

PRs welcome! Areas for improvement:

  • Migration script for different workspace layouts
  • Automated MEMORY.md size monitoring via cron (see cron template)
  • Domain file templates for common use cases
  • Integration tests with memory_search
  • memorybox watch β€” daemon mode for continuous monitoring
  • Qdrant/local vector search integration for Tier 2 semantic retrieval

πŸ“œ License

MIT β€” Do whatever you want.


πŸ“Š Star History

Star History Chart


Made with 🦞 by @ramsbaby

Battle-tested on a production OpenClaw instance running 24/7 with 48 crons and 7 channels.

About

🧠 Install once, forget about memory management. Zero-dependency maintenance CLI for OpenClaw agents. Works alongside Mem0, Supermemory, QMD.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors