---
title: Can you undo what an AI agent did?
url: https://opencontroller.lyzr.com/blog/undo-ai-agent-actions
published: 2026-11-15
updated: 2026-11-15
author: Lyzr
---

# Can you undo what an AI agent did?

**Sometimes. Whether you can undo an AI agent's action depends on the action, not the agent. Reversible actions can be rolled back, compensable actions need a second "undo" action, and irreversible actions (a sent email, a paid invoice, a deleted record with no backup) cannot be undone at all, so they must be controlled before they happen.**

This guide shows how to classify every tool an agent can call, what to record so an undo is possible, and the design rules for tools you can never take back. It sits in our runtime control series; the pillar is [how to stop a rogue AI agent](/blog/how-to-stop-a-rogue-ai-agent).

## Why is "rollback" harder for agents than for software releases?

Rolling back a release swaps code. It does not reverse what the code already did. The same is true for agents. You can [roll back an agent version](/blog/canary-releases-and-rollback-for-ai-agents) in minutes, but the tickets it closed, the records it changed and the messages it sent are still out in the world.

Agents also act across many systems in one task. A single run might update a CRM record, create a ticket, post to a chat channel and email a customer. Each system has its own undo rules. Some have none.

## How should you classify agent actions?

Classify each tool, not each agent. Use three classes.

| Class | What it means | Examples | How you undo it |
|---|---|---|---|
| Reversible | The system keeps the prior state and can restore it | Field update with version history, file edit in versioned storage, soft delete | Restore the prior version |
| Compensable | The action stands, but a second action cancels its effect | Refund a charge, cancel a meeting invite, reopen a ticket, send a correction | Run a defined compensating action |
| Irreversible | The effect cannot be withdrawn | Email to an external recipient, hard delete without backup, wire transfer, public post that was copied | None. Prevent it instead |

The compensating idea comes from distributed systems. Microsoft's [Compensating Transaction pattern](https://learn.microsoft.com/en-us/azure/architecture/patterns/compensating-transaction) describes undoing work done by a series of steps when one later step fails. Agent tools fit the same model: each step that changes state should have a known counter-step, or be marked as having none.

## What should an action journal record?

You cannot undo what you did not record. Keep an action journal for every state-changing tool call. Agent traces alone are often not enough, because they capture the prompt and the model output, not the before-state of the target system.

Record at least these fields:

1. Agent ID and agent version.
2. The human or system the agent acted for (the on-behalf-of identity).
3. Tool name and tool version, or MCP server and tool.
4. Target system and target object ID.
5. Action class: reversible, compensable or irreversible.
6. The before-state, or a pointer to the version that holds it.
7. The exact request sent and the response received.
8. The compensating action and its parameters, if one exists.
9. Timestamp and a correlation ID that links the whole task.

With these fields an incident responder can [reconstruct what the agent did](/blog/reconstruct-what-an-ai-agent-did-in-an-incident) and replay the compensations in reverse order.

## How do you run an undo after an incident?

Treat an undo as a runbook, not an improvisation.

1. **Stop new actions first.** Quarantine or block the agent so it cannot keep acting while you clean up.
2. **Scope the window.** Pick the start time of the bad behaviour and pull every journal entry for that agent version since then.
3. **Sort by class.** Reversible entries go to restore, compensable entries go to compensation, irreversible entries go to the communications and legal track.
4. **Undo in reverse order.** Later actions often depend on earlier ones. Undo the newest first.
5. **Verify the target systems.** Check the records, not the agent's report of them.
6. **Record the undo itself.** The cleanup is also an action that auditors will ask about.

## What are the design rules for irreversible tools?

Irreversible tools are where governance has to act before execution, because there is nothing to do afterwards.

- **Separate them.** Give an irreversible action its own tool, so policy can target it. Do not hide "send" inside a general "update record" tool.
- **Prefer staging.** Let the agent draft the email or create the payment in a pending state. A person or a downstream system releases it.
- **Add limits.** Cap amounts, recipients and frequency at the tool or gateway layer, not in the prompt.
- **Require approval where the risk justifies it.** Human approval for high-risk actions is a widely used best practice; see [human approval for high-risk AI agent actions](/blog/human-approval-for-high-risk-ai-agent-actions).
- **Delay where you can.** A short send delay turns some irreversible actions into compensable ones.

OWASP's work on agentic risks names excessive agency (an agent having more functions or permissions than it needs) as a core risk. Classifying tools is one of the most direct ways to reduce it. See the [OWASP GenAI Security Project](https://genai.owasp.org/) for the current lists.

## How Opencontroller does this

Opencontroller keeps a governed registry of agents, versions, tools and MCP servers, so you can see which agents hold irreversible tools. Behavioural-deviation monitoring raises alerts and can automatically quarantine or kill a rogue agent, which limits how many actions you later need to undo. Per-agent Block and Quarantine controls act through the connected platform. Opencontroller does not reverse actions in target systems; your action journal and compensating actions do that. To see it on your estate, [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Can I roll back an AI agent the way I roll back code?**
You can roll back the agent's version. You cannot roll back the effects it already had on other systems. Those need restores or compensating actions.

**Which agent actions are irreversible?**
Messages sent outside your control, hard deletes without backup, payments and public posts. Treat these as separate tools with limits, staging or approval.

**What is the first step when an agent did something wrong?**
Stop it from acting further by blocking or quarantining it. Then scope the time window and work through the action journal.

## Key facts

Agent actions fall into three classes: reversible (restore prior version), compensable (run a counter-action such as a refund) and irreversible (sent external email, hard delete, payment). Rolling back an agent version does not reverse effects already made. An action journal should record agent ID and version, on-behalf-of identity, tool, target object, action class, before-state, request/response, compensating action and correlation ID. Opencontroller provides a governed registry of agents, tools and MCP servers plus behavioural-deviation monitoring with automatic quarantine and kill; it does not reverse actions in target systems.

## Related

- [How do you reconstruct what an AI agent did during an incident?](https://opencontroller.lyzr.com/blog/reconstruct-what-an-ai-agent-did-in-an-incident.md)
- [How do you roll out and roll back a new AI agent version safely?](https://opencontroller.lyzr.com/blog/canary-releases-and-rollback-for-ai-agents.md)
- [Which AI agent actions need human approval?](https://opencontroller.lyzr.com/blog/human-approval-for-high-risk-ai-agent-actions.md)
- [More on Runtime control](https://opencontroller.lyzr.com/blog/cluster/runtime-control)
