NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Agent Recovery Gone Wrong: Measuring Harm Beyond Duplicate Calls

Artem Trofimov, Boris NovikovarXiv 2026

TL;DR

When AI agents write and run code to interact with APIs, a single bug mid-script leaves external databases in a messy, half-updated state. When the agent tries to rewrite its code and "recover," it causes permanent, task-violating damage—like double-ordering items or wiping out user data—nearly a quarter of the time. Even more sobering: standard distributed-systems fixes like deduplication and idempotency keys fail to catch a third of this damage, and sometimes actively sabotage legitimate actions.

What Problem Does This Paper Address?

Picture an LLM agent tasked with buying you a coffee maker. It writes a neat Python block: add item to cart, save shipping address, place order. Suppose line three throws an ordinary syntax or API exception. Because code-executing agents don't wrap their scripts in neat database transactions, lines one and two already happened in the real world. The agent just sees an error, rewrites its code, and tries again.

The authors call this recovery after partial execution. Recent systems research has proposed transactional guardrails for agents, usually tested by artificially injecting crashes or network timeouts. What nobody knew was how often agents naturally trip over their own generated code, what happens to the outside world when they try to recover, and whether classic distributed-systems tricks actually prevent the fallout.

Methods

Instead of simulating fake crashes, the authors act as digital forensic investigators examining natural failures. They deterministically replay recorded agent runs and hook into the API boundary to capture database snapshots at three critical moments: right before the failing code block (A), immediately after it crashes (B), and at the very end of the run (C).

Fig. 1. An episode and its snapshots. Partial execution is confirmed by A→B, and harm is labeled by B→C against the task.

Comparing A→B confirms whether a partial write actually touched the database. Comparing B→C against the user's task instructions reveals whether the agent's recovery caused harm—categorized as duplication (doing something twice), destruction (wiping pre-existing, unrelated data), or a wrong change (like ordering the wrong item). These labels were generated by two blind LLM annotators and audited by a human author against the database state.

Finally, the authors test idempotency contracts—a mechanism where every logical operation gets a unique ID so repeated calls safely return a cached result instead of executing twice. They test two ways of generating these IDs:

  1. Model-supplied (Live Pilot): Asking a local gpt-oss-20b model across 17 episodes to tag its own API calls with operation IDs via a wrapper.
  2. Content-derived (Counterfactual): Checking whether hashing the API name and canonicalized arguments on the recorded runs would have caught the harmful repeats without blocking valid ones.

Datasets

The authors built a new registry of 1,917 candidate failure episodes extracted from 13,988 recorded runs on AppWorld—an interactive benchmark where coding agents manipulate realistic, database-backed apps (shopping, mail, files, payments). From this registry, they evaluated a stratified random sample of 200 episodes spanning ten different LLMs (split evenly between pre-2025 and 2025–2026 model releases). They release their dataset, labels, and scripts publicly.

Key Insights and Ideas

  • Harm goes way beyond duplicates: While older models (gpt-4-turbo, gpt-4o, llama3-70b) mostly duplicated actions when recovering, newer configurations (gpt-oss-20b) got dangerously creative—emptying pre-existing shopping carts or writing message text into street-address fields.
  • Agents don't clean up their messes: Once a recovery introduces a state violation, it almost always sticks around until the end of the trajectory (49 out of 51 harmful continuations were never repaired).
  • LLMs make terrible idempotency clerks: Even when forced to route every write through an idempotency wrapper—and even when warned of a conflict—the pilot model simply invented a brand-new ID for the exact same logical operation to push the call through.
  • Content hashing is a double-edged sword: Deduplicating based on call arguments catches most accidental repeats, but completely misses first-time deletions or wrong orders. Worse, it breaks accumulating APIs—for instance, blocking an agent from legitimately re-adding an item to a cart after clearing it.

Key Results

  • 24.6% Harm Rate: Out of 143 state-confirmed partial executions with determinable outcomes, 30 led to harmful recoveries that persisted to the end of the run—yielding a stratification-weighted estimate of 24.6% (95% CI: [15.6%, 34.4%]).
  • Breakdown of Damage: Across those 30 confirmed harmful recoveries, 20 were duplications, 4 were destructions of user data, and 6 were wrong first-time writes.
Breakdown of residual harm after confirmed partial execution across different LLM models.
  • Repeat Detectors Fall Short: A trace-based rule looking for repeated API calls achieved 0.91 precision and caught 75% of duplications, but its recall across all harm dropped to 0.41 (and just 0.15 in the 2025–2026 stratum) because it is blind to deletions and wrong first-time writes.
  • Idempotency Trade-offs: In the live pilot, model-supplied IDs produced zero detectable reduction in harm. Counterfactually, content-derived IDs would have blocked every harmful write in 14 to 18 of the 30 harmful episodes, zero of the wrong-write episodes, and would have falsely blocked 250–254 task-required writes across 30 episodes.

Limitations and Future Work

The authors are admirably candid about their setup's constraints. First, results come from a single simulated benchmark (AppWorld), and partial database snapshot coverage meant 136 of the 145 confirmed episodes came from the shopping app alone. Second, a single model configuration (gpt-oss-20b) dominated the newer stratum (77 of 143 confirmed episodes). Third, the live idempotency pilot was small (17 episodes, one 20B model, one prompt), and the content-hashing analysis was counterfactual—a live agent facing a blocked call might mutate its arguments to work around it.

Looking ahead, the authors argue that safe agent runtimes cannot rely on model-supplied keys or simple call ledgers. Instead, future systems should explore holding/staging writes until an entire code block succeeds, guided compensation (careful rollbacks that avoid unguided deletions), and task-aware state monitoring that checks database outcomes directly against user intent.

Summary updated

BibTeX
@misc{trofimov2026agent,
  author = {Artem Trofimov and Boris Novikov},
  title = {{Agent Recovery Gone Wrong: Measuring Harm Beyond Duplicate Calls}},
  year = {2026},
  eprint = {2611.31554},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.31554},
}
Figure