Code-executing LLM agents submit blocks of code that issue several API writes. If a block fails after some of its writes have taken effect, the agent rewrites the block and continues. It is unknown how often such a recovery harms the external state when the failure occurs naturally in the code written by the agent. In this paper, we measure it on recorded trajectories of AppWorld agents. In a stratified random sample of 200 candidate episodes across ten models, 145 are partial executions confirmed by the database state. In the sample, 30 of 143 confirmed partial executions with a determinable outcome are followed by a harmful recovery, and its violation remains at the end of the run, which gives a stratification-weighted estimate of 24.6%. Two thirds of the harmful recoveries duplicate an effect, and the rest delete user data or make a wrong first-time write, e.g., an order of a wrong product. A rule that searches for repeated calls finds 75% of duplications but only 41% of all harm. We also examine two sources of operation identity for an idempotency contract. In a small pilot (17 episodes, one local model), identifiers supplied by the model do not detectably reduce harm, because the model issues a new identifier for the same operation. Identity derived from the call content, evaluated counterfactually on the sample, would have matched every harmful write in 14 to 18 of the 30 harmful recoveries, but in none of those with a wrong first-time write, and it would also have matched writes required by the task in 30 episodes. Based on these results, we outline design requirements for safer agent recovery.
Figures & tables
Fig. 1: An episode and its snapshots. Partial execution is confirmed by A → B, and harm is labeled by B → C against the task.
Model
Conf.
Harm
Dupl.
Destr.
Wrong
gpt-4-turbo
24
8
7
0
1
gpt-4o
22
6
5
1
0
llama3-70b
10
3
3
0
0
deepseekcoder-33b
4
0
0
0
0
gpt-oss-20b
77
11
4
3
4
other models a
6
2
1
0
1
TABLE I: Residual harm after confirmed partial execution by model
Signal
Target
Precision
Recall
Rule B
all harm
0.91
0.41
Rule B
duplication
0.91
0.75
Multiplicity test
all harm
0.95
0.35
Multiplicity test
duplication
0.95
0.64
TABLE II: Repeat-based signals against state-and-task labels (195 sampled episodes with a determinable label)
n
Harm
Resid.
Byp. req.
Byp. writes
A
17
6
8
–
–
B
17
6 a
7
36/451
16/168
C
17
5
7
503/823
11/80
D
10
4
6
97/135
21/38
E
17
7
8
0/184
0/129
a 6 or 7 depending on one disputed label. Harm undeterminable
TABLE III: Pilot with model-supplied identifiers. A: no wrapper; B: observe; C: enforce; D: reference identifiers; E: enforce and reject bypass. Harm: continuations with a harmful action. Resid.: continuations with a violation in C, including one left by the failed block. Byp.: writes outside the wrapper among all write requests and among successful writes
Total
Strict
Lenient
Ids
Harmful writes matched
132
100
104
118
duplication
113
96
96
110
destruction
4
0
3
3
wrong change
15
4
5
5
Recoveries fully matched a
30
14
16
18
duplication
20
14
14
16
TABLE IV: Counterfactual matching on canonical arguments in the 30 harmful recoveries after confirmed partial execution