# Your Coding Agent Can't Undo Its Own Mistakes - Tanmay Sah & Dolly Sah
<!--
ref: @content/youtube/aie/2026-11-08-your-coding-agent-can-t-undo-its-own-mistakes-tanmay-sah-dolly-sah
version: 1
updated_at: 2026-11-08T13:34:52.867Z
-->

**[Watch on YouTube](https://www.youtube.com/watch?v=BT1Mo-fD-g0)**


*Synthesized from Tanmay Sah and Dolly Sah's talk on AI Engineer, 2026-11-08.*

Tanmay Sah and Dolly Sah present two research projects, UndoBench and Evo-Undo, at an AI Engineer event; there is no host.

## Core Thesis
Tanmay Sah and Dolly Sah argue that the ability to complete a task does not mean an agent can recover from failure. Many agent effects sit outside Git: external API calls, runtime configuration, notifications, and changes to the agent's own execution environment. They propose that recovery be built in as a first-class capability. Before a change happens, the agent captures the prior state as a "witness." An independent verifier then checks that restoration works, and self-modifications are accepted only when they pass both a capability bar and a recoverability bar.

## Key Insights
- **Task success is not recovery success (UndoBench).** The researchers ran 2,880 paired trials comparing normal runs with runs that had an injected failure.
  - Agents succeeded 84% of the time under normal conditions.
  - Only 47% of the normally successful trials recovered correctly once a failure was introduced.
  - Tanmay notes the two figures use different denominators, but the gap is still large.
- **A timeout is not a failure.** In Tanmay's example, an agent asks an external system to create a ticket. The server creates ticket #781, but the confirmation is lost on the way back. The agent sees a timeout and retries without checking, which produces a second ticket. In UndoBench, naive retries caused duplicate effects in 54% of such trials. The core distinction is between a failed *response* and a failed *operation*.
- **Recovery strategy depends on when the failure happened:**
  - **Before the mutation:** retrying is usually safe because nothing has changed.
  - **During the mutation:** the system may be partially changed, so the agent must inspect the current state.
  - **After the mutation:** the effect may already be recorded even though the confirmation was lost, so a retry risks duplicates.
- **Git revert covers only part of the problem.** Coding agents also change their execution state, such as tool registries, middleware, and configs. They also cause external effects, such as deployments and database writes. The undo mechanism has to match the type of effect.
- **Self-modifying agents make recovery harder.** When agents change their own prompts, tools, middleware, event listeners, resources, and routing configurations, they can become more capable and less recoverable at the same moment.
- **Undo needs the prior value, not just an inverse command.** To reverse a timeout change from 30 to 60, the agent has to know the original was 30. Evo-Undo records this "state witness" before mutating. The witness is used both to restore the state and to verify the restoration.
- **Capability gains often carry recovery defects (Evo-Undo).** The team ran 600 evolution tasks:
  - 478 improved capabilities.
  - 197 of those improvements had recovery defects, about 42% of the successful improvements.
- **Prompting the agent to "please undo" did not work.** Four verifier-guided remediation strategies, using the original recovery language, fixed none of the 197 natural failures. Tanmay says the cause was not mainly poor reasoning. It came from two bottlenecks:
  - **State grounding.** The agent lacked accurate information about the initial state. Giving it precise information on what changed and where raised recovery from 0 to 38 of 48 cases.
  - **Recovery expressiveness.** The recovery language could not express the needed undo operation. Richer undo operations raised recovery from 0 to 142 of 143 cases.
  - These results come from separate experimental subsets.
- **An expanded recovery language rescues most failed mutations.** It recovered 180 of the 197 broken mutations, about 92%. Admissible improvements rose from 281 to 461 of 600 tasks, a 30-percentage-point gain.
- **The Evo-Undo loop, as Dolly describes it:**
  1. The agent proposes a mutation using the current state, an effects contract, and a recovery plan.
  2. In a test environment, the agent applies the mutation and runs the recovery plan.
  3. Before the real mutation, a state witness of the initial state is captured.
  4. An independent verifier checks whether the original state was actually restored.
  5. If the mutation improves capability by the user's criteria and passes the recovery check, it is accepted. Otherwise, the agent tries to fix it or the verifier rejects it.

  Resilience becomes part of the decision to admit a change, rather than something handled after deployment.
- **Running an undo command does not prove a restore.** In the 30→60 example, the saved witness drives the restore back to the original value. The verifier then confirms that the resulting state matches the original, rather than trusting that the command executed.
- **Different failures need different responses:**
  - **Nothing changed:** retry safely.
  - **Initial state is known and restorable:** restore it.
  - **External effect already recorded:** run a compensating action to cancel it.
  - **Cannot restore, cannot verify, or the verifier rejects the restore:** stop and escalate to a higher level.

## Actionable Takeaways
1. Treat timeouts as "unknown outcome," not "failed." Before retrying a mutating external call, such as ticket creation, check whether the first call already took effect.
2. Classify each failure by phase (before, during, or after the mutation) and pick the strategy for that phase. Only blind-retry failures that happened before the mutation.
3. Do not rely on Git revert alone. Inventory the effect types your agent produces (repo files, runtime config, tool registries, middleware, deployments, DB writes, notifications) and define an undo or compensation mechanism for each.
4. Before any mutation, read the current value and store it as a state witness (e.g., timeout = 30) so the restore target is exact.
5. Verify restores independently. Compare the post-undo state to the witness rather than treating "undo command ran" as success.
6. For self-evolving agents, rehearse the change in a test environment first: apply the mutation, run the recovery plan, and check it with an independent verifier. Accept the change only if it meets both the capability criteria and the recoverability check.
7. If recovery fails, invest in grounding and expressiveness rather than better prompting:
   - Give the agent precise information about what changed and where.
   - Expand its recovery operations so it can express the needed undo.
8. Use compensating actions for external effects that cannot be reversed. Escalate to a human or higher-level system when the restore cannot be completed or verified.
9. The Evo-Undo project is available in the authors' GitHub repository, linked via QR code in the talk.

## Notable Quotes
> "A timeout means that a response was not received, not that the operation failed." — Tanmay Sah

> "An agent can become more capable, but at the same time less recoverable." — Tanmay Sah

> "A mutation can improve an agent's capabilities but leave the system incapable of reliable recovery." — Tanmay Sah

> "Resiliency becomes part of the admission decision, rather than something we strategically plan for after the AI agent is deployed." — Dolly Sah

> "By giving agents more autonomy, we should also provide them with more robust ways to recover from their actions." — Dolly Sah

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*