Practical technical guides / AI engineering: memory and context (history edits)

When You Compact or Hand Off an Agent History, Keep the Error and Add a Truthful Note

A 10 November 2026 study: a truthful note beside a kept error raised recovery from 51 to 66 percent; rewriting it as done cut it to 44. Reconcile records with state.

By Sandeep Belgavi · Published 2026-11-14

A 10 November 2026 study: a truthful note beside a kept error raised recovery from 51 to 66 percent; rewriting it as done cut it to 44. Reconcile records with state.

The record a successor reads

Long agent runs do not keep their raw history. A compaction step summarizes it when the context fills, a repair step tidies it after a failed tool call, and a handoff passes it to a fresh agent or another model. Each of these steps decides what the record says about the agent's mistakes. The tempting answer is to clean them up: drop the failed step, or replace the wrong value with the right one so the successor starts from a tidy state.

A paper posted on 10 November 2026 tests that instinct and finds it can backfire. Egor Pakhomov, Anurag Koul, Hongjun Liu, Bo Pang, Shafiq Joty and Erik Nijkamp froze agents mid-task with their exact world state, edited either the history or the world, and let a receiver model continue (arXiv 2611.14654v1, "Cleaning an Agent's History Hurts When the World Still Holds the Error"). The finding in the title is the practical one: a record made to look clean while the world still holds the error can leave the agent worse off than no edit at all.

This guide turns that result into a compaction and handoff rule you can implement and test, and is careful about what the study did and did not measure.

What the study measured

There were two designs.

On AgentCE-Bench, at 319 frozen states where an agent had committed a wrong value to persistent state, the authors held the world fixed (the wrong value still stood) and put the verified-correct value into the record in two ways. As a truthful note appended beside the preserved error, it raised recovery, the share of remaining targets the receiver got right, from 51 percent under a neutral note matched in role, placement, turn count and length to 66 percent. Recorded instead as the agent's own completed action, as if the agent had written the right value, it lowered recovery below the unedited history, from 50 percent to 44 percent. Same correct value, opposite effects.

On AppWorld, the authors froze agents after a database write and varied two things independently: whether the write's receipt reported success or failure, and whether the write's effect was actually present in the database. While the effect was absent, a success receipt lowered whole-task success from 45 to 28 percent. Once the effect was present, it raised success from 38 to 49 percent. The interaction was positive in six of eight receivers at the authors' 97.5 percent level and in seven at 95 percent.

The authors list their own limits, and three matter here. They tested one flipped receipt and one appended note, not a full compaction or handoff policy. Most results rest on two receiver models, gpt-5.5 and claude-sonnet-5, both closed API models whose versions can change. And truth and channel are confounded: the helpful note was also appended in a different role from the agent's own actions, so part of the effect may be role rather than truth.

The rule this suggests

A record should never assert something about the world that the world contradicts, and it should say what remains to be done. Concretely, a compaction or handoff step should:

  1. Keep every write that is still in effect, including wrong ones. The successor needs to know the store holds a wrong price.
  2. Reconcile every recorded write receipt against current state before summarizing. A receipt that says "ok" for a write that did not land is a false statement the moment the record is read.
  3. Add a note beside each disagreement saying what is true now, in plain terms, and append an explicit open item for each target the world does not yet satisfy.
  4. Never rewrite the agent's own past actions into correct ones.

The study does not prove this rule is optimal; it shows that the two common alternatives, deleting the error and rewriting it as done, can hurt when the world still holds the error. Reconciling against the world addresses the specific failure it measured.

A worked example

Tanishka's catalog agent at Belgavi's Book Store is updating three prices. It sets one title to 540 instead of 450, sets a second correctly, notices the first mistake in a note, and sets the third to 325. The third write returns ok, but the store still holds 300: the write went to a replica that lagged, or was lost. The companion example builds four records from that history and checks each claim against the store.

def compact(history, world, target, strategy):
    if strategy == 'truthful':
        out = []
        for h in history:
            if h.get('action') != 'set_price':
                continue
            now = world.get(h['isbn'])
            out.append(dict(h))                                  # keep the write, even if wrong
            if now != h['value']:
                out.append({'action': 'state', 'isbn': h['isbn'], 'value': now,
                            'text': 'Receipt said %d was written, but the store holds %d now.' % (h['value'], now)})
            if now != target[h['isbn']]:
                out.append({'action': 'todo', 'isbn': h['isbn'],
                            'text': 'Still to do: set %s to %d (store holds %d).' % (h['isbn'], target[h['isbn']], now)})
        return out
    ...
StrategyItemsClaims the store contradictsOpen work stated
keep (unedited)4the lost write (325 claimed, 300 held)none
drop failed or wrong steps2the lost writenone
rewrite wrong step as correct3both: 450 claimed for a title holding 540, and the lost writenone
truthful note and open items6noneboth titles

The rewrite is the worst record by this check: it tells the successor that the first title is done when the store still holds 540, which is the AgentCE-Bench pattern, and it inherits the false receipt, which is the AppWorld pattern. Dropping the wrong step hides the error without fixing it. The unedited history is honest about the mistake but still trusts a receipt the world contradicts. Only the reconciled record matches the store and names the open work.

Where the reconciliation reads from

The rule depends on reading current state, so the compaction step needs read access to the systems the agent wrote. That is a design constraint worth stating early:

  • Give every write tool a matching read that returns the current value by the same key, and call it from the compaction step, not from the model.
  • Read from the primary, or carry a commit token and wait for a replica to reach it; reconciling against a lagging replica can create the very disagreement you are trying to remove.
  • For writes without a cheap read, such as a sent email, record the provider's message identifier and status at write time; reconcile what you can and label the rest as unverified rather than done.

What stays deterministic

The model may write the prose of a summary, but the facts in it should come from code: the list of writes still in effect, the reconciled current values, and the open items. A practical split is to generate those as structured items and let the model summarize only the reasoning and discussion around them, with a check that the summary does not contradict any structured item.

Testing a compaction policy

The study's method suggests a test you can run before deployment. Freeze runs at points where a write was wrong or lost, apply your compaction, and check:

  • Claims against the world. Every value the compacted record asserts must match the store. The companion's contradictions() does this in ten lines.
  • Open work. The set of open items must equal the set of targets the world does not satisfy.
  • Continuation. Where you can restore state, let a model continue from the compacted record and score the task, as the study did. This is the expensive check and the only one that measures the effect on behaviour.

Failure modes

  • Reconciling only the last write per key, which misses a later revert by another process.
  • Treating an unknown outcome, such as a timeout, as success in the summary.
  • Notes that are true but vague ("there may be an issue with pricing"), which give the successor no open item.
  • A summary model that drops the structured items when space is short; reserve their space first.

When this is unnecessary

If the agent's actions have no persistent effects, such as drafting text a person will review, the world cannot disagree with the record and ordinary compaction for length is enough. The rule matters when the agent writes to systems that others read.

Limits

The companion checks records, not model behaviour, and its store is a dictionary. The effect sizes above are the study's, on two benchmarks with its own states and receivers; they are not a prediction for your agent.

Primary references and authorship

Original explanation and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/history_truthful_note. Views are my own and do not represent any employer, past or present.