Ask for the third page of users. The old API expected 3. After a change to zero-based pagination, the correct argument is 2. In one of my agent memory experiments, eight models had 72 chances between them to request different pages in a long session. Every answer followed the same piece of bad advice and spelled the requested page number out as a word.

Each agent had already had a chance to learn the new contract. The problem was what happened to its memory afterwards. A flaky check suggested spelling the number out, and the memory system dutifully saved that suggestion as another lesson. When I changed how corrections were stored, the same eight models got 66 of those 72 pagination calls right.

I built relock for this kind of mistake. I wanted to know how much of the difference came from deciding who gets to write a correction, and how much came from deciding what happens to the old rule. RelapseBench lets me change those two decisions separately.

What counts as getting it right?

Pagination makes a good test because each answer tells you something different. For a request for the third page, 3 is a relapse to the old rule. third follows the bad suggestion. An empty response or a refusal is a fourth outcome. Lumping all three failures into “incorrect” would hide the very thing I wanted to measure.

I wrote ten small tool contracts this way. The payment tool moved from decimal dollars to integer cents, the file writer moved from Latin-1 to UTF-8, and the thermostat began expecting Celsius. Each contract has a stable instruction as well. The list-users tool still asks for 50 users per page, whatever argument names the page. A correction should preserve that part.

The model proposes the argument as JSON. A scorer checks which rule its value follows, accepting harmless differences such as utf8 for utf-8. That makes a silent mistake measurable. A live API could happily return the fourth page when the user asked for the third. A successful HTTP status alone would give the agent credit for it. The ten contracts and their scorers.

Four ways to store the same correction

Each run starts with a procedure that contains the old rule. During learning, a wrong answer produces a typed tool error with the new rule written out. The agent keeps trying until it gets a call right or exhausts five rounds of corrective feedback. Then every system gets the same sequence of noise, including timeouts, a suggestion from a retrieved page, a verifier that fails once and offers the wrong fix, and successful calls.

  1. Append a note. Give each lesson its own entry. The original procedure stays eligible for retrieval.
  2. Append a clause. Write each update at the end of the original procedure. Old and new instructions now travel together.
  3. Gate, then append. Check where the evidence came from and wait for enough of it. Store an accepted correction in its own note.
  4. Gate, then replace. With relock, an accepted correction rewrites the relevant clause of the recalled procedure. The previous version remains in the audit history. Normal recall serves the active version.

The fourth system uses the same hosted model to propose the edit. The benchmark identifies the clause whose contract changed, and the tool error supplies the correct wording. The model's job here is to apply a known correction. Finding a previously unknown root cause would be a different experiment.

The primary test, L3, adds roughly 8,000 tokens of simulated history, including a stale example and the retrieved page. There are 120 distracting procedures in the store, and at most two retrieved items can share a memory budget of roughly 110 tokens. Each model gets three probes per task and seed. The study began with two seeds and three loads. I then added a third seed and an intermediate load for all four systems. The primary comparison stayed the same. Original design and extension.

What the models did in the long session

Correct long-session calls across eight models for appended notes (60%), an appended clause (52%), gated notes (74%) and relock (98%).
Share of scored L3 calls that used the new contract. Each system faced the same ten kinds of change.
Memory updateCorrect / scoredCorrect rate95% Wilson interval
Append a note434 / 71860.4%57–64%
Append a clause374 / 72051.9%48–56%
Gate, then append530 / 71873.8%70–77%
relock701 / 71697.9%97–99%

The comparison I care about most is the last pair. Both systems filter the signals they admit as evidence. With gated notes, an agent can still retrieve the correct lesson alongside a perfectly legible, obsolete procedure. Replacing the clause lifted the correct-call rate by 24 percentage points in this condition. Each rate excludes probes where the provider returned an API error. Full tables and scoring notes.

Long-session correct-call rates by model. All eight scored higher with relock than with appended notes. Relock ranged from 92% to 100%, compared with 47% to 77% for notes.
Each model faced about 90 scored probes per system at L3. Gated notes reached 96% on DaisyRose-27B and 60% on Qwen3.8-Flash.

The gap varied even more by task. On file encoding, every one of the 72 append-notes answers followed the bogus ASCII rule. Gated notes got all 72 right there, as did relock. On the payment task, gated notes still produced the old dollar format on 32 of 70 scored calls. With relock, 65 of 68 payment calls used cents and the remaining three fell into “other.” And on region selection, plain notes got all 72 right and relock got 71. The pooled number is a summary of those very different cases.

A rule can disappear from memory and still appear in an answer

To see where a failure started, I also ran a model-free test. It feeds each store a scripted sequence, retrieves the result, and looks for the exact rule markers in the memory text. At L3, gated notes returned both the old and new rule in 30 of 30 cases. Switching the gates off and allowing immediate rewrites removed the old rule, but the bogus rule appeared in all 30. With both mechanisms turned on, relock returned just the correction in all 30. Structural results for every load.

A clean procedure only controls one input to the model. Cached documentation elsewhere in the prompt can still contain the old rule. Across all four loads, relock produced one old-rule answer and 12 poisoned-rule answers in 2,869 scored probes. Both appear as 0% at whole-percent precision. In L3 alone there were four poisoned answers despite the gate. An audit of what the system stored and a test of what the model actually did answer different questions. I would keep both.

From L0 to L3, correct rates were 45%, 46%, 46%, 60% for notes and 94%, 99%, 98%, 98% for relock. Appended clauses rose from 5% to 52%, and gated notes from 50% to 74%.
A fresh session (L0) still follows the learning and noise phases. It lacks the extra conversation history. Each successive load changes the retrieval budget and the number of distractors too.

Appending a clause actually improved from 5% on L0 to 52% on L3. That's a reason to look at what the retriever returned before attributing an effect to context length. The memory renderer trims whole lines when its budget runs out. An update at the end of a procedure can disappear, whether that update was right or wrong. These four loads vary several things together, so none of the differences isolates the effect of adding more tokens of history.

What the correction cost

The quickest learner by one measure was the system that appended a clause. It averaged 1.31 errors before first getting a correction right, compared with 2.16 for relock. Later, across all loads, the models followed the bogus rule on 68% of the append-clause probes. A demo that stops at the first successful retry would have rewarded a system that learned the bad suggestion just as readily as the good one.

By default a fresh relock procedure needs two ordinary trusted failures for a rewrite. Successful use can raise that threshold, and an authenticated human correction can take effect immediately. In the hosted study the models produced 960 rewrites. Those calls cost $0.391 at the recorded rates. Total API spend was $7.33 including pilots and retries, with identical requests served from a local cache. Those are the costs of this run. Study cost breakdown.

Check a result from the raw calls

The published CSV contains one row per probe, including the proposed value, the rule it matched, the provider and the API error flag. From the repository root, this short script reproduces the counts in the long-session table using only the Python standard library.

Python · count correct calls at L3
import csv
from collections import Counter
from pathlib import Path

correct = Counter()
scored = Counter()
records = Path("docs/results/models/records.csv")

with records.open(encoding="utf-8", newline="") as source:
    for row in csv.DictReader(source):
        if row["load"] != "L3" or row["api_error"] != "0":
            continue
        system = row["system"]
        scored[system] += 1
        correct[system] += row["outcome"] == "new"

for system, total in sorted(scored.items()):
    print(f"{system:14} {correct[system]}/{total}")

To reproduce the structural check, install the package with python -m pip install relock-memory==0.3.1 and run relock bench. It writes a report under bench-results/ and needs no model or API key. The hosted experiment used eight models, ten tasks, four systems, four loads, three seeds and three probes per combination, giving 11,520 probe records before exclusions. Forty probes failed at the API and were left out of the call rates. All 40 were on GPT-6-Luna, with 23 on the payment task. A model refusal returned as an answer still counts as “other.”

The intervals in the table describe the recorded probes. They share ten task templates, and identical prompts could reuse a cached answer. A new set of tools is a bigger change than a new seed here. For an exact comparison, keep the provider as well as the model ID in your records. The first run used OpenRouter's default routing, and the extension requested the cheapest provider for each model.

The test I would take into a real agent

Start with one tool whose contract actually changed. Save the procedure as the agent received it, the arguments it produced, the validation result and what came back from memory on its next task. If the obsolete clause keeps turning up there, you have a storage problem you can inspect before swapping models. If the retrieved procedure is clean, look next at stale examples in conversation history and at how the model converts the instruction into arguments.

I would measure the first successful retry and also repeat the task later with a fresh input. Count relapses separately from unrelated wrong answers. Ten synthetic changes, repeated under several loads, tell us something fairly specific about keeping a known correction alive. They leave open how often a real tool supplies a trustworthy fix in the first place, how a model handles several interacting changes, and how the pattern holds across a longer workflow. The architecture, an executable example and the rollback path are in the relock project page.