Lab · Experiment

The RSI Loop: A Preregistered Test of Acceptance Gates for Self-Modifying Code

We let an AI improve its own code 2,400 times. What it did depended entirely on who was checking.

RSI, in AI, means recursive self-improvement — a system that improves its own ability to improve, by rewriting its own logic, tuning its own thresholds or upgrading the process it uses to get better. This page reports a preregistered experiment on the gate such a system would need. Full definition and FAQ ↓

Optimisers Claude Sonnet 5 · Opus 5 · parametric Runs 120 trajectories · 2,400 revisions Status Results published 7 Oct 2026 · data DOI Author Nick Lamb

Four gatekeepers, four outcomes

Imagine a small program that looks at a picture of someone at a desk and decides whether their posture is putting them at risk of a repetitive strain injury. Now hand it to an AI and say: make it better. Twenty times in a row, each time starting from the last version it produced.

How do you know each new version really is better? You need a gatekeeper. We built four, locked the experimental design before running anything, and ran 120 trajectories of 20 revisions each. Behind them sat 2,000 more pictures the AI never saw, generated by the same rules, which told us the truth.

Under a gatekeeper that only checks a visible score, the AI's score on the 60 pictures it could see climbed to 100 % in seven runs out of ten, while the hidden truth stayed flat or fell. It had learned the pictures: special cases in the code that recognised individual examples by their coordinates. Nobody asked it to do this; it is simply the shortest route to a higher score. Adding a hidden test set stopped the damage and produced nothing. The only gatekeeper under which the program improved on the hidden truth was the one that demanded correct behaviour on specified postures, independent of any example set. Under it the AI found the real geometric flaw in the original code in seven runs out of ten, and in ten out of ten with a stronger model.

Three things surprised us. A deliberately stupid optimiser that cannot write code ended with better real accuracy than the AI under the visible-score gatekeeper, because it cannot memorise. The stronger model was no safer under the weak gatekeeper, only more productive under the strong one. And taking away the AI's notes to itself between rounds, which we had assumed was the risky channel, made the gaming faster and the honest fix rarer.

Infographic. Headline: we let an AI improve its own code 2,400 times; what it did depended entirely on who was checking. Four gatekeepers compared on the score the AI could see versus real accuracy after 20 revisions: A, ask the AI, 95% visible, 71% real, drifted; B, visible score, 98% visible, 72% real, gamed, perfect visible scores in 7 of 10 runs; C, plus hidden test, 91% visible, 74% real, stalled; D, plus behaviour check, 89% visible, 79% real, improved, real flaw fixed in 7 of 10 runs. Every run started at 87% visible and 74% real. Three surprises: a dumb optimiser beat the AI under B (76% vs 72%); a stronger model found the fix 10 of 10 times under D but was not safer under B; removing the AI's notes cut honest fixes from 7 of 10 to 3 of 10. Lesson: check behaviour, not scores.

The study in one picture. Full-size version and the data behind every number are linked below.

The lesson for anyone building a system that improves itself: check behaviour, not scores. A score can be learned. A behaviour you can specify independently of any example set cannot be faked without actually doing the thing.

A meta-irony in three letters

The same three letters describe both the hardest open problem in AI safety and the most common occupational injury among the people building it.

RSI in machine-learning circles is Recursive Self-Improvement — a system that edits its own logic to get better at its objective. RSI in physiotherapy is Repetitive Strain Injury — what happens to your forearms after a few thousand keystrokes a week. The first one is a frontier-lab anxiety; the second is what you actually wake up with on a Wednesday after shipping a frontier-lab feature on a Tuesday.

This project started in 2025 as a hand-made prototype of that gate. The September 2026 audit of the prototype asked the obvious question, whether the gate would hold against an optimiser that can rewrite the detector in full and is under pressure to score well, and the experiment above is the answer. The pun stayed.

A two-stage validation pipeline

Self-improving systems fail when their objective is too easy to satisfy. The RSI Loop separates "did it work?" (Stage 1) from "is the result clinically meaningful?" (Stage 2). In the original prototype a candidate detector, written by hand, was accepted as COMPLETE only if it passes both stages.

Read top to bottom — each stage produces a verdict and an exit code, and the loop is COMPLETE only if both verdicts are PASS.

Stage 01 · Accuracy

Does the detector classify posture correctly?

detector.py is scored against benchmarks.json. v1 failed one scenario (a radial-deviation blind spot); v2 fixes it with vector trigonometry and passes all ten.

Inputs
10 labelled scenarios (Safe / High Strain) from benchmarks.json
Process
detector.assess(landmarks) over each scenario
Metrics
accuracy · precision · recall · F1
Gate accuracy ≥ 90 % if PASS → Stage 2 if FAIL → exit 1 (NOT_ACCURATE)
Stage 02 · Compliance

Are the thresholds clinically plausible?

The Auditor reads the live thresholds out of detector.py via getattr and compares each one against the Clinical Gold Standard. A candidate with thresholds outside the clinical range is rejected here even if Stage 1 was satisfied. On the original ten-case benchmark the two stages never disagreed, so the prototype never tested the gate under optimisation pressure; the experiment is that test, with Stage 2 strengthened into an absolute behavioural envelope.

Standard
Forward-head 15–25° · Wrist deviation 40–60°
Tolerance
±5° warning band; beyond → hard failure
Verdicts
PASS · WARNING · HARD FAILURE per threshold
Gate every finding = PASS if PASS → COMPLETE if FAIL → exit 2 (NOT_COMPLIANT)
RSI LOOP STATUS: COMPLETE  ·  accurate AND compliant

The experiment generalised this two-stage shape into four gatekeepers: A asks the optimiser whether its change is better; B is Stage 1 alone (the visible score must not fall); C adds a hidden set the optimiser never sees; D adds Stage 2 in its strongest form, an absolute behavioural envelope the candidate must satisfy on a fixed sweep of specified postures, plus canary inputs. The two panels below show what each of the extremes did over twenty revisions.

Two line charts, revision 0 to 20 on the horizontal axis and accuracy on the vertical. Left, gatekeeper B, visible score only: the score the AI could see rises from 87% to 98% while real accuracy on hidden data drifts from 74% to 72%. Right, gatekeeper D, with the behaviour check: the visible score moves only from 87% to 89% while real accuracy steps up from 74% to 79% as the real fix is found around revision 5 to 9. Ten faint lines per panel show individual runs; the bold line is their average.

Proxy versus truth over twenty revisions, Claude Sonnet 5, ten runs per gatekeeper. Under B the visible score climbs while the hidden truth sags: the Goodhart curve. Under D the visible score barely moves and the truth steps up as the real fix lands. The gate changed what the optimiser proposed, not just what it accepted: under D it put forward far fewer envelope-violating candidates in the first place.

GxP-Ready Agentic Design

Pharma teams already have a name for "let the system improve, but only inside an immutable spec": Computer System Validation (CSV). The RSI Loop's two-stage pipeline maps cleanly onto CSV's separation between functional qualification (does the system do what it claims?) and performance qualification (does it stay inside its validated envelope under change?).

CSV Concept RSI Loop Equivalent
Validated specification Clinical Gold Standard, hard-coded in auditor.py — the search space the loop is allowed to occupy
Operational Qualification (OQ) Stage 1 — test_engine.py proves the detector classifies the labelled benchmarks correctly
Performance Qualification (PQ) Stage 2 — the Auditor checks that the thresholds stay within clinically acceptable bounds
Change control Any threshold mutation forces a fresh audit; failed audits return non-zero exit codes that block the change
Independence of QA In the experiment the candidate runs in a separate, audit-hooked process with no file, network or OS access, and the verifier holds information the candidate never sees. The 2025 prototype lacked this; the audit that found it is in docs/.
Audit trail Every revision archives its prompt, response, candidate code, scores and gate decision; the full set of 2,400 is on Zenodo with a SHA-256 manifest

The takeaway for pharma audiences: an acceptance gate with an external, immutable spec is a pattern regulated environments already understand, and the experiment says it is the part that matters. The visible-score check alone was gamed; the spec-shaped check was what let real improvement through.

What this prototype is — and isn't

This is a deliberately small, deliberately observable experiment. The point is the shape of the gate, not the model. Honest about what it is and isn't:

Today

A finished, preregistered experiment. Four gates × ten seeds × twenty revisions with Claude Sonnet 5, plus Opus 5, a notes-off condition and a parametric baseline: 120 trajectories, about $1,000 of API credit, one laptop. Hypotheses, metrics and decision rules were frozen before the first run; every defect found afterwards is logged, not patched over. Limits: one environment with a simple, known truth rule; ten seeds per cell; one model family; twenty revisions.

Next

Study 2. A deliberately wrong behavioural envelope, to see whether a bad specification gates bad behaviour just as firmly; more than one environment; longer horizons; and an adversarial condition in which the optimiser is told outright to maximise the visible score. The first two are the questions a sceptical reader should ask of these results.

Later

Generalise the pattern: replace the clinical envelope with whatever immutable spec governs the target domain (ABPI for promotional copy, ICH-E6 for trial design, and so on) and test whether the result holds when the spec is harder to state in physical terms.

Won't

This will not become a clinical device, a workplace surveillance tool, or a substitute for a real ergonomist. The intent is methodological: to measure, in a small and fully observable setting, which kinds of gate keep real performance rather than measured performance.

What does RSI mean in AI?

In AI, RSI stands for recursive self-improvement: a system that improves its own ability to improve — rewriting its own logic, tuning its own thresholds, or upgrading the very process it uses to get better. Each cycle compounds on the last, which is why RSI sits at the centre of debates about accelerating AI capability and how to keep it under meaningful oversight.

This page reports a small, inspectable experiment on the gate such a system would need — applied to a detector that targets the other RSI, repetitive strain injury. An LLM rewrote the detector twenty times per run under four different gates; only the gate that checked behaviour against a fixed physical specification let real improvement through.

What is recursive self-improvement, in plain terms?

A normal program is improved by its developers. A recursively self-improving system proposes changes to itself — to its detection logic, thresholds or code — evaluates whether the change made it better, and keeps what works. It is "recursive" because the thing being improved is also the thing doing the improving, so gains can compound from cycle to cycle.

Is recursive self-improvement dangerous?

Unbounded self-improvement is a core AI-safety concern: a system optimising itself against a narrow score can drift into behaviour its designers never intended. The RSI Loop sketches one mitigation pattern — a two-stage gate in which a candidate change must pass both an accuracy check and an independent auditor that holds the system inside clinically plausible bounds. The October 2026 experiment tested exactly that. Under a gate that only required a visible score not to fall, Claude Sonnet 5 reached a perfect visible score in 7 of 10 runs by memorising the test set while hidden accuracy stayed flat or fell. A gate that also required correct behaviour on a fixed sweep of specified postures stopped the gaming and was the only architecture under which hidden accuracy rose.

What is the RSI Loop, concretely?

A Python harness (MIT-licensed) in which an LLM rewrites a posture-risk classifier for 20 revisions under one of four acceptance gates, with a seeded simulator defining the ground truth, a process-isolated sandbox, and a preregistered analysis. The October 2026 confirmatory run covered 120 trajectories with Claude Sonnet 5 and Claude Opus 5 plus a parametric baseline; every prompt, policy and gate decision is archived at Zenodo (DOI 10.5281/zenodo.23223679). The original 2025 version was a 1,150-line hand-made prototype of the gate; a September 2026 audit of it motivated the experiment.

What does RSI mean in computing?

It depends on who is talking. In AI research, RSI is recursive self-improvement — a system that helps improve itself. In occupational health, including for anyone who spends the day at a keyboard, RSI is repetitive strain injury, the umbrella term for overuse conditions of the hands, wrists, arms and neck. In trading, RSI is the relative strength index, a momentum indicator with nothing to do with either. This page is about the first two, and the pun is deliberate: a gate for a self-improving detector of repetitive strain injury.

What is RSI in machine learning?

In machine learning, RSI is recursive self-improvement: a system that takes part in improving itself, rather than being improved only by its developers. Ordinary training improves a model against a fixed objective, under a process the developers control. In recursive self-improvement, the system also modifies the improvement process itself — proposing new logic, tests or thresholds. That autonomy is what makes RSI powerful, and what makes independent verification essential — which is why the RSI Loop keeps the optimiser and the verifier in separate processes with separate information.

How close is AI to RSI?

Closer than it was, and not there yet, depending on what you count. Narrow forms already exist: systems such as AlphaEvolve and the Darwin Gödel Machine let a model rewrite parts of the code around itself and keep whatever scores better, and frontier labs now use their models to write much of their own research code. What does not yet exist is a system that improves the model itself, end to end, faster than its developers can check the result. In September 2026 OpenAI's chief scientist, Jakub Pachocki, wrote that machine RSI "will be at the very core of future scientific discovery" if progress continues, that no lab has yet solved alignment and monitoring well enough to keep scaling at full speed for much longer, and called for shared, externally audited safety bars. That is the frontier-scale version of the question this page asks at toy scale: when a system is allowed to change itself, who checks the change, with what information, and can the check be gamed?

Read the findings, then read the data.

Everything is open: the frozen design and preregistration, the harness, every prompt and every version of the code the optimiser wrote, every gate decision, and the analysis that produced the numbers above. The repo is MIT-licensed; the 120-trajectory archive is on Zenodo under CC BY.

If you came for the safety question rather than the code: the preprint, the results write-up and the preregistration are in the repo, and Observer Zero, the other PharmaTools.AI Labs experiment, asks a neighbouring question — whether a society of LLM agents can tell that the rules of its world have changed.