Outer-loop memory for the harness optimizer, not runtime prompt bloat for the task-solving agent.
An engineering implementation of Self-Improvement Memory (SIM) from Self-Improvement Memory Enables Continual Recursive Self-Improvement (arXiv:2611.18856), built to run on top of Muster and integrate with Persona as an optional extension.
Traditional agent experience systems stuff prose lessons into the task-solving agent's context. Over time, defensive checklists accumulate, slow down every routine task, dilute attention, and become impossible to prune when models improve.
SIM flips the architecture:
- Zero runtime context tax:
sim.jsonis read only by the outer-loop harness optimizer (Proposer & Selector), never by the task-solving agent. - Code/hooks/deletion before prose: The optimizer is steered (and scored) to prefer removing obsolete rules > writing deterministic hooks/scripts/tools > shrinking prompts > adding short prompt lines.
- Speed Canary hard gates: Every eval suite pairs
eval/failures/(real regressions) witheval/canaries/(routine fast tasks). Any edit that slows down routine canaries beyond budget (default+15%wall time or+20%turns) or exceeds prompt byte caps is rejected in code, regardless of score gain. - Shared Base + Per-Model Overlays: Supports
claude-code,codex, andagyvia thin adapters. Keeps deterministic tooling in a sharedbase, isolates model-sensitive tuning inoverlays/<model>.json, and providessim reauditto prune obsolete crutches whenever you upgrade models. - Clean isolated execution: Runs evals under
/tmp/sim-runs/<id>/(outside$HOMEto sever upwardCLAUDE.md/AGENTS.mdinheritance), usesgit worktree+ Copy-on-Write (cp -cRon macOS APFS /--reflink=autoon Linux) for whitelisted skills/frozen memory snapshots, and runs a fail-fast Preflight Probe before every run. - Native memory harvester (
sim harvest): Deterministically audits host auto-memory dirs (~/.claude/projects/*/memory,~/.codex/memories,~/.gemini/antigravity-cli/memory) for oversized files (>4 KB), staleness (>60d), and cross-project repeated pitfalls ready to be promoted into deterministic hooks via SIM.
Zero third-party dependencies (Python 3.10+ standard library only):
# Optional editable install (or invoke ./bin/sim directly)
pip install -e .
# 1. Create a target (single model or --multi-model across claude-code / codex / agy)
./bin/sim init my-repo --repo ~/repos/my-repo --multi-model
# 2. Verify clean sandbox isolation & print env_fingerprint
./bin/sim preflight targets/my-repo --json
# 3. Run baseline evaluation (failures + speed canaries)
./bin/sim eval targets/my-repo --json
# 4. Run one SIM evolution round (directly or via Muster workflow)
./bin/sim evolve targets/my-repo --via direct --json
./bin/sim evolve targets/my-repo --via muster
# 5. Cross-model subtraction audit after upgrading your policy model
./bin/sim reaudit targets/my-repo --policy claude-main --json
# 6. Audit host native harness memories for bloat & promotion leads
./bin/sim harvest --json
# 7. Clean up temporary sandbox directories
./bin/sim gc --dry-run
# 8. Serve loopback HTTP status API for the Persona plugin
./bin/sim serve --port 8133 --token "<secret>"An overlay is validated on one model, so SIM never writes it into a file every model reads (CLAUDE.md,
CLAUDE.local.md): another model would get a rule nobody measured on it, and an isolated git worktree does not
carry untracked files anyway. Whatever starts the agent knows the model, so it asks SIM at start time and puts the
output before the task prompt, where SIM evaluated it:
sim rules --harness claude --model small-model[1m] --cwd ~/repos/my-repo
# <sim-rules target="my-repo" model="small-model" rev="1f0c…">…</sim-rules> (empty output: nothing to add)- Only policies naming exactly this harness and model match; any other model gets nothing.
--cwdmay be a path on another machine: a target matches by its repository's name as a directory component (match_reposintarget.json, default the repo's basename).--jsonadds provenance (target, policy, overlay,rev, ledger problems).- Model-agnostic results (hooks, skills, scripts,
CLAUDE.mdedits) belong in the repository as commits, so every launcher and worktree sees them.
sim/
├── sim/
│ ├── ledger.py # SIM JSON ledger (problems, aliases, carried_from, staleness)
│ ├── config.py # target.json schema (optimizer, policies, editable caps, env)
│ ├── adapters.py # Thin adapters: claude-code, codex, agy, mock
│ ├── sandbox.py # /tmp/sim-runs isolation, git worktree, CoW cp -cR, Preflight, GC
│ ├── eval.py # Failure + Speed Canary runner & code-level Hard Gates
│ ├── prompts.py # SIM Proposer / Selector / Reauditor prompts & JSON schemas
│ ├── evolve.py # Outer-loop CRSI round & cross-model reaudit
│ ├── harvest.py # 0-LLM native harness memory diet & promotion scanner
│ ├── serve.py # Loopback HTTP API for the Persona dashboard
│ ├── cli.py # `sim` CLI
│ └── flows/
│ └── evolve_flow.py # Native Muster workflow (`muster run sim/flows/evolve_flow.py`)
├── plugin/ # Persona extension (`extension_protocol: 1`, UI only, NO memory_sources)
├── tests/ # Unit & end-to-end tests (offline via `mock` adapter)
└── bin/sim # Executable entrypoint
See plugin/README.md. The extension exposes nav_page and overview_card only — it intentionally does not contribute memory_sources, keeping SIM strictly out of runtime chat prompts.
MIT