English | 中文
An open-source Recursive Self-Improvement (RSI) engine — let your AI Agent rewrite its own code, verify in sandboxes, and evolve automatically.
OpenRSI explores how AI systems can improve themselves systematically, verifiably, and safely. Instead of treating "self-improvement" as a single vague concept, OpenRSI separates it into two complementary tracks:
- Harness-RSI — Evolving everything around the model (agent code, prompts, tools, memory, workflows, and search strategies) while keeping model weights frozen.
- Model-RSI — Evolving the model's internal weights through self-generated trajectories, verifiable rewards, and automated post-training loops.
Both tracks share the same core scientific loop: Propose → Execute in Sandbox → Verify & Score → Gate & Archive. Together, they form a dual-loop flywheel:
flowchart TB
subgraph Outer["Outer Loop: Harness-RSI (Fast, Low-Cost)"]
H1["Current Harness<br/>(Code / Prompts / Tools / Workflows)"] --> H2["Diagnose Failures &<br/>Propose Patch"]
H2 --> H3["Isolated Sandbox<br/>Run & Evaluate"]
H3 --> H4{"Score Improved &<br/>Checks Pass?"}
H4 -- Yes --> H5["Commit & Archive<br/>New Lineage"]
H4 -- No --> H6["Rollback & Log<br/>Failure Trace"]
H5 --> H1
H6 --> H1
end
subgraph Inner["Inner Loop: Model-RSI (Deep, High-Ceiling)"]
M1["Current Model Weights"] --> M2["Rollout & Self-Play<br/>in Sandbox"]
M2 --> M3["Automated Verifier<br/>(Tests / Execution / Rubrics)"]
M3 --> M4["Post-Training<br/>(SFT / DPO / GRPO / RLVR)"]
M4 --> M5{"Held-Out Eval<br/>Gate Pass?"}
M5 -- Yes --> M6["Promote Checkpoint"]
M5 -- No --> M7["Discard & Adjust<br/>Curriculum"]
M6 --> M1
M7 --> M1
end
H5 -. "Verified trajectories &<br/>distillation data" .-> M3
M6 -. "Stronger base model<br/>proposes better patches" .-> H2
- Harness-RSI feeds Model-RSI: A stronger harness (better search, verification, and tool use) solves harder problems and produces high-signal, verified trajectories that can be distilled into model weights.
- Model-RSI feeds Harness-RSI: A stronger base model diagnoses subtle harness bugs more accurately and writes higher-quality code/prompt mutations in fewer iterations.
| Dimension | Harness-RSI | Model-RSI |
|---|---|---|
| What Evolves | Agent source code, prompts, tools, memory, routing, search & planning logic | Neural network parameters (LoRA / full weights) |
| Model Weights | Frozen (works with closed APIs or open weights) | Updated via automated training loops (requires open weights) |
| Iteration Cycle | Minutes to hours | Hours to days |
| Compute & Cost | Low — API / inference cost + lightweight sandboxes | High — GPU cluster for rollouts + RL/SFT training |
| Primary Methods | Code self-editing, prompt optimization, tool synthesis, evolutionary archive (e.g., MAP-Elites) | Rejection sampling (STaR), RLVR (GRPO/PPO), DPO, self-play curriculum |
| Rollback & Auditability | Trivial — git revert and human-readable diffs |
Heavier — checkpoint versioning and benchmark regression suites |
| Main Failure Modes | Overfitting to benchmark tests, reward hacking, brittle patches | Model collapse, catastrophic forgetting, reward hacking |
| Best Starting Point | Start here — fast feedback, transparent diffs, immediate utility | Build next — once verified tasks and harness trajectories exist |
- Verifiable Progress Over Vibes: Every self-modification must be judged by deterministic execution, unit tests, or strictly isolated evaluation suites—never by an ungrounded self-score alone.
- Immutable Evaluator, Mutable Target: The agent is allowed to edit the target harness or generate training data, never the grading harness or held-out test set.
- Sandbox-First Safety: All candidate code changes and model rollouts execute inside isolated sandboxes with strict resource, network, and time limits.
- Lineage & Archive Over Blind Greedy Hill-Climbing: Keep a versioned tree of candidates so evolution can branch, backtrack, and preserve diverse solutions rather than collapsing into a local optimum.
- Reproducible & Open: Every evolution run should emit inspectable traces, diffs, scores, and seeds.
Using zero extra API cost (powered locally by codex exec via ChatGPT OAuth), OpenRSI automatically evolved context compactors from naive sliding-window baselines:
- OpenRSI Context-Compaction Arena (
14k–15ktokens →18%budget, hiddenpytest):- Baseline v0 (sliding window) →
0.000on train & unseen held-out - RSI Gen 3 (auto-evolved deterministic extractor) →
1.000(8/8) on train &1.000(8/8) on unseen held-out (83.4%compression)
- Baseline v0 (sliding window) →
- CompactBench Official Full
practiceSuite (Elite Difficulty — 48/48 cases, ~32k tokens, 8 adversarial families mixed, 4 drift cycles, 4,546 probes):OpenRSICompactorv1 (RSI-evolved Delta Evidence Ledger):0.762 [95% CI: 0.740, 0.784](3,535/4,546full-credit probes, drift resistance0.815, decay+0.164(0.90 → 0.69),0.0%trap rate,0.0%hallucination rate,0budget violations;provenance_authority: 0.98,decision_override: 0.95,entity_confusion: 0.92) — see full 48-case breakdown inharness-rsi/reports/cb_leaderboard.md.
openrsi/
├── README.md # Project overview, architecture & results (EN)
├── README_zh.md # Project overview (ZH)
├── harness-rsi/
│ ├── README.md / README_zh.md # Harness-RSI architecture & quickstart
│ ├── arena/
│ │ ├── fix-mini-kvstore/ # Harbor sandbox task (nop=0.0, oracle=1.0)
│ │ └── context-compaction/ # Long-horizon compaction benchmark (Train + Held-out)
│ ├── harness/
│ │ ├── compactor.py # Evolved deterministic compactor (v1 arena)
│ │ └── cb_compactor.py # Evolved Delta Evidence Ledger (CompactBench)
│ ├── evolver/ # `openrsi` CLI, Codex client, evaluator & RSI engine
│ └── reports/ # Evolution curves, archives & CompactBench leaderboard
└── model-rsi/
├── README.md / README_zh.md # Model-RSI architecture & roadmap
└── requirements-colab.txt # GPU training dependencies (for Colab Phase 3)
- Phase 0 — Specification & Architecture
- Dual-track
harness-rsiandmodel-rsiarchitecture, interfaces, and safety boundaries.
- Dual-track
- Phase 1 — Harness-RSI MVP
- Harbor sandbox task (
fix-mini-kvstore), long-horizoncontext-compactionarena,CompactBenchintegration via localcodex exec, automatic keep/rollback gating, and evolution curve plotting.
- Harbor sandbox task (
- Phase 2 — Multi-Branch Archives & Live Agent Middleware
- MAP-Elites population archive, multi-objective Pareto tracking, and live
codex app-servercompaction middleware.
- MAP-Elites population archive, multi-objective Pareto tracking, and live
- Phase 3 — Model-RSI Pipeline
- Automated rollout harvesting, verifier filtering, and pluggable SFT / GRPO / RLVR training recipes on open-weight models.
- Phase 4 — Dual-Loop Co-Evolution
- Close the flywheel: distill Harness-RSI breakthroughs into Model-RSI checkpoints, and feed promoted checkpoints back into Harness-RSI.
- Read Harness-RSI to see how an agent rewrites and verifies its own code and workflows.
- Read Model-RSI to see how models self-improve their weights via verified rollouts and post-training.