# Your Coding Agent Can't Undo Its Own Mistakes

Tanmay Sah & Dolly Sah | AI Engineer CODE 2026 | 16:38

Source: https://www.youtube.com/watch?v=BT1Mo-fD-g0
Channel: AI Engineer (https://www.youtube.com/@aiDotEngineer). Summarised by AIE Talks.
Page: https://aietalks.com/talks/your-coding-agent-cant-undo-its-own-mistakes
Published: 2026-11-08
Tags: agents, coding-agents, guardrails, reliability, testing

## TL;DR
- An agent that completes a task successfully may still fail to recover when a later operation breaks.
- Retries can duplicate external effects because a timeout does not prove that the original operation failed.
- EvoUndo admits an agent mutation only when it improves capability and passes an independently verified recovery check.

## Summary
Tanmay Sah and Dolly Sah argue that coding agents need a recovery capability alongside their ability to complete tasks. Git can restore repository files, but it cannot undo API calls, runtime configuration changes, notifications, deployments, or database writes. In UndoBench, agents succeeded on 84% of normal trials, while only 47% of normally successful trials recovered after an injected failure. Naive retries created duplicate effects in 54% of the relevant trials. Their second project, EvoUndo, tests changes to an agent's execution environment by saving a pre-mutation state witness, applying the change, running its recovery plan, and checking the result with an independent verifier. The agent can retry, restore, compensate for a committed external action, or escalate when safe recovery cannot be established. The experiments found that 197 of 478 capability-improving changes introduced recovery defects. Extending the recovery language restored 180 of those 197 cases.

## Key ideas
### Successful task execution does not guarantee recovery
[01:05](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=65s)
UndoBench tested whether an agent that can finish a task can also recover after something goes wrong. The researchers ran 2,880 paired trials, comparing normal execution with execution after an injected failure. Agents reached an 84% success rate under normal conditions. Among trials that succeeded normally, only 47% recovered successfully after failure. Tanmay points out that the percentages have different denominators, but the result still shows a clear gap between completing an operation and putting the system back into a safe state.

### A timeout can hide a committed external action
[02:13](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=133s)
Tanmay gives the example of an agent creating a ticket through an external system. The server creates ticket 781, but the acknowledgement is lost before reaching the agent. The agent sees a timeout and does not know whether the request committed. If it sends the request again without checking, the system ends up with two tickets instead of one. In UndoBench, naive retries produced duplicate effects in 54% of these trials. Recovery therefore has to distinguish a failed response from a failed operation.

### Recovery depends on when the failure occurs
[03:42](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=222s)
The same recovery action is not safe at every point in an operation. Before a mutation, retrying is generally safe because nothing has changed. During a mutation, the system may have been changed only partly, so the agent needs to inspect its state. After a mutation, the operation may already have committed even when the acknowledgement was lost. Retrying at that point can create duplicates. The failure phase determines whether the agent should retry, inspect, restore, or take another action.

### Git cannot undo effects outside the repository
[04:55](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=295s)
Git can restore repository changes, but coding agents also alter runtime state. Tanmay names tool registries, middleware, and configurations, as well as external effects such as deployments and database writes. Git revert does not reverse these actions. The recovery mechanism must match the type of effect that was created. This becomes harder when agents modify their own execution environment, including prompts, tools, middleware, event listeners, resources, and routing configurations.

### A pre-state witness gives undo the value it needs to restore
[05:54](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=354s)
Undoing a mutation requires knowing the original state. If an agent changes a timeout from 30 to 60, an inverse command alone does not tell it whether 30 was the previous value. EvoUndo captures a pre-state witness before applying the mutation. The witness records the state that should be restored and later gives the verifier something concrete to check. This lets recovery target the actual prior value instead of guessing from the mutation command.

### Capability improvements can create recovery defects
[07:03](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=423s)
EvoUndo evaluated 600 evolution tasks. Of those, 478 produced capability improvements, and 197 of those improvements also introduced recovery defects. That is about 42% of the capability-positive cases. The result means an agent can become better at performing a task while becoming harder to recover when the change causes trouble. The researchers tested four verifier-guided repair strategies, but none recovered the naturally occurring failures under the original recovery language.

### Recovery needs state information and expressive operations
[08:07](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=487s)
The failed repairs came from two different limits. Sometimes the agent did not have precise information about what had changed or where. Providing that state grounding improved recovery from 0 to 38 of 48 cases. In other cases, the recovery language could not express the operation needed to reverse the change. Adding richer undo operations improved recovery from 0 to 142 of 143 cases. Both the state description and the available recovery action have to be sufficient.

### EvoUndo makes recoverability part of admitting a mutation
[10:42](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=642s)
Dolly describes an admission process for agent evolution. The system starts with the current state, an effect contract, and a recovery plan. It captures a state witness before applying the mutation, then tests the mutation and recovery plan in an environment. An independent verifier checks whether the original state was restored. A mutation is admitted only if it improves capability according to user-defined criteria and passes the recovery check. Otherwise, the agent tries to repair it or the verifier rejects it.

### The response should match the effect that actually occurred
[13:36](https://www.youtube.com/watch?v=BT1Mo-fD-g0&t=816s)
Dolly separates four responses. If nothing changed, the agent can safely retry. If the original state is known, it can restore that state. If an external action already committed, it may need a compensation action that reverses the effect. If safe recovery cannot be verified, the agent should stop and escalate. EvoUndo therefore does not apply one undo procedure to every failure. It chooses based on the system state and on what can safely be reversed.

## Notable quotes
- Tanmay Sah: "A timeout tells us that the response didn't arrive, not that the operation failed." (02:43)
- Tanmay Sah: "An agent can become more capable while becoming less recoverable." (05:54)
- Dolly Sah: "The recovery isn't considered successful simply because an undo command was run." (13:13)
- Dolly Sah: "The right response definitely depends on what actually happened and what can be safely reversed or not." (14:29)

## Tools & references mentioned
- UndoBench
- EvoUndo
- Git

## Who should watch
- You are building coding agents that call external APIs, change runtime configuration, or trigger deployments and need to handle partial failures safely.
- Your agent can retry operations after timeouts, but you have not checked whether the first request already committed.
- You are working on agent self-evolution and need a way to reject improvements that make later recovery impossible.

## Editor's note

Tanmay Sah shows that among trials that succeeded normally, only 47% recovered successfully after an injected failure. Kitaru records every model call and tool result from a real agent run, then replays the code with the same inputs and tool responses. That gives a failed production run a repeatable test case for checking whether a change improves recovery without touching real systems.

Written by the AIE Talks editors (the Kitaru team), not by the speaker.

## Related talks

- [Your coding agent doesn't always follow your rules](https://aietalks.com/talks/your-coding-agent-doesnt-always-follow-your-rules) (Talha Sheikh, Checkout.com, 10:08)
- [Your AI Agent Is Hiding Its Mistakes From You](https://aietalks.com/talks/your-ai-agent-is-hiding-its-mistakes-from-you) (Ben Holmes, Warp, 19:20)
- [Your Agent Fix Just Broke Something Else](https://aietalks.com/talks/your-agent-fix-just-broke-something-else) (Sofia Jakovcevic, Arize AI, 19:25)
- [Pick Problems That Survive When AI Solves Coding](https://aietalks.com/talks/pick-problems-that-survive-when-ai-solves-coding) (Ara Khan, Cline, 26:49)
- [Respect The Process](https://aietalks.com/talks/respect-the-process) (Andrew Dumit, Watershed Technology Inc., 16:43)
