Skip to content
Ghost-LZWPublic

About

Self-Improvement Memory (SIM) for continual outer-loop optimization of agent harnesses, built on Muster and Persona.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

SIM — Self-Improvement Memory for Agent Harnesses

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.

Why SIM instead of runtime "experience" Markdown?

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:

  1. Zero runtime context tax: sim.json is read only by the outer-loop harness optimizer (Proposer & Selector), never by the task-solving agent.
  2. 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.
  3. Speed Canary hard gates: Every eval suite pairs eval/failures/ (real regressions) with eval/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.
  4. Shared Base + Per-Model Overlays: Supports claude-code, codex, and agy via thin adapters. Keeps deterministic tooling in a shared base, isolates model-sensitive tuning in overlays/<model>.json, and provides sim reaudit to prune obsolete crutches whenever you upgrade models.
  5. Clean isolated execution: Runs evals under /tmp/sim-runs/<id>/ (outside $HOME to sever upward CLAUDE.md / AGENTS.md inheritance), uses git worktree + Copy-on-Write (cp -cR on macOS APFS / --reflink=auto on Linux) for whitelisted skills/frozen memory snapshots, and runs a fail-fast Preflight Probe before every run.
  6. 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.

Quick start

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>"

Per-model rules in daily runs (sim rules)

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.
  • --cwd may be a path on another machine: a target matches by its repository's name as a directory component (match_repos in target.json, default the repo's basename). --json adds provenance (target, policy, overlay, rev, ledger problems).
  • Model-agnostic results (hooks, skills, scripts, CLAUDE.md edits) belong in the repository as commits, so every launcher and worktree sees them.

Architecture

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

Persona Extension

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.

License

MIT

About

Self-Improvement Memory (SIM) for continual outer-loop optimization of agent harnesses, built on Muster and Persona.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages