The Agent Failed Midway Through Execution — What Happens to the Data It Already Changed?

When an Agent's cross-system multi-step execution partially fails, idempotent retries and reverse compensation (Saga) must work together to handle side effects that cannot be rolled back.
Starting from a real scenario encountered by a Reddit developer: an Agent creates a GitHub issue, sends a Slack message, and writes to Notion in sequence; the third step fails due to a typo in the database ID, but the first two steps have already produced visible effects on the outside world. The author points out that the root cause is that the Agent's multi-step operations span multiple stateful systems, lack distributed transaction coordination, and that once side effects are visible they are hard to recall. The article reviews the limitations of three common strategies — manual cleanup, idempotent retries, and accepting inconsistency — and introduces the reverse undo approach used by AgentRein, which is essentially the Saga pattern landing in the Agent toolchain, executing compensation actions in reverse order. The author emphasizes that compensation has clear boundaries: payments, PR merges, release deletions, and similar operations are irreversible, and Slack undo replaces content rather than deleting it. Finally, it offers engineering lessons: distinguish reversible from irreversible steps during design, place irreversible operations later or add confirmation, recognize that compensation is not the same as leaving no trace, and understand that tools cannot replace architectural responsibility allocation.
When an Agent Crashes at Step Three, But Steps One and Two Already Changed Real Data
This is the problem every developer who puts an Agent into production will eventually run into. A developer on Reddit described his test scenario: an Agent executes three actions in sequence — creating a GitHub issue, sending a Slack message, and writing to a Notion database. In one run, the Notion step failed because of a typo in the database ID, but by then the GitHub issue had already been created and the Slack message had already been sent. Those two steps had already produced real effects on the outside world.
The question he posed was blunt: do you clean up manually today, do idempotent retries, or just accept the inconsistency?

Why This Problem Is Harder Than It Looks
Single-step failure itself is nothing new. What's new is that an Agent's multi-step operations span multiple stateful systems, and there is no transaction coordination between those systems. A traditional backend can roll back with database transactions, but external services like GitHub, Slack, and Notion are each independent, and no distributed transaction protocol is there to back you up.
What's worse is that the side effects are already "visible": the issue may have been seen by a colleague, and the Slack message may have already sparked a discussion. Even if you could technically undo them, the spread of information within that time window cannot be recalled.
Distributed transactions and two-phase commit (2PC) are the classic protocols traditional backends use to handle cross-system consistency: the coordinator first asks all participants whether they can commit, and only after everyone agrees does it commit uniformly; if any one fails, everyone rolls back. But 2PC requires participants to implement prepare/commit interfaces and hold locks, and SaaS services like GitHub, Slack, and Notion do not expose such interfaces, nor can they let external systems hold locks for long periods. So the Agent toolchain cannot simply copy 2PC and must settle for eventual consistency: allowing intermediate states to exist briefly and then converging through compensation or reconciliation. Once you understand this, you can see why "rollback" in Agent scenarios often manifests as "reverse operations" rather than "transaction undo."
Three Common Strategies Today
Looking at community discussions and engineering practice, there are roughly three paths.
Manual Cleanup
The most direct but also the least scalable. For small-scale, occasional failures, you can manually close the issue, edit the Slack message, and clean up the Notion entry. The problem is that the value of an Agent lies precisely in automation; once the failure rate is high, the cost of manual compensation eats up the gains from automation.
Idempotent Retries
Make each step idempotent so that retries do not produce duplicate side effects. This is the first choice for many teams, but it only solves the "retry without duplication" problem — it does not solve the case where "the third step itself is unrecoverable." For example, if the Notion database ID is wrong, retrying any number of times will fail, and the side effects of the first two steps still hang there.
Idempotency means that executing the same operation once and executing it multiple times has the same effect on system state. In HTTP semantics, GET, PUT, and DELETE are defined as idempotent, while POST is not. Common engineering implementations include: the client generates a unique idempotency key and sends it with the request, and the server records the processed keys and directly returns the first result; or a deduplication table is used to check the business unique identifier before writing. For Agent calls to external APIs, most SaaS providers support carrying an idempotency key in the request header (such as Stripe's Idempotency-Key), but interfaces like GitHub issue creation and Slack message sending do not guarantee idempotency by default. The Agent side must maintain its own state record of "whether it has already executed," otherwise retries will produce duplicate side effects.
Accept Inconsistency
Some teams choose to log and reconcile periodically, accepting short-term state drift. This approach is feasible in scenarios where side effects are minor and can be corrected afterward, but it carries high risk for operations involving payments or customer-visible content.
An Idea for Reverse Compensation
The poster himself is building a tool called AgentRein, and the idea is reverse undo: wrap existing SDK clients so that when a step is recorded as failed, the previously completed steps are undone in reverse order. In his test, after Notion failed, the tool closed the created GitHub issue and edited the Slack message to "Reverted by AgentRein."
This idea is essentially the Saga pattern landing in the Agent toolchain — each step is paired with a compensation action, and on failure the compensations are executed in reverse order.
Clear Capability Boundaries
The poster listed the limitations himself, which is worth praising, because the boundaries of a compensation mechanism determine whether it can be trusted:
- Covers 9 connectors: GitHub, Slack, Stripe, HubSpot, Notion, Gmail, Google Sheets, Drive, Salesforce (the last three are still in preview)
- Irreversible operations: merging PRs, deleting GitHub releases, Stripe charges and refunds
- Slack undo replaces the message content rather than deleting the message
These limitations illustrate a key fact: not all side effects can be compensated. Payment operations and irreversible publishing actions have no way back once executed.
The Saga pattern was first proposed by Hector Garcia-Molina and Kenneth Salem in 1987 to solve the problem that long-lived transactions cannot hold locks. Its core is to split a long transaction into several local transactions T1…Tn, each Ti paired with a compensation action Ci; if Tk fails, then C(k-1)…C1 are executed in reverse order. Saga has two implementation styles: choreography, where each service listens for events and triggers compensation itself, and orchestration, where a central coordinator drives a state machine. Tools like AgentRein that wrap SDKs are closer to orchestration — it needs to record the execution state and compensation action of each step in order to determine the scope of reverse undo on failure. Saga guarantees semantic compensation rather than atomicity, so the compensation actions themselves may also fail, and you need to design retry and escalation paths for human intervention.
Lessons for Agent Engineering Practice
Treat "Compensability" as Part of Step Design
When designing Agent workflows, you should distinguish in advance which steps are reversible and which are not. Reversible steps can safely be placed early; irreversible steps (payments, publishing, deletion) should be placed as late as possible, or a confirmation step should be added before execution. This way, even if later steps fail, the scope that needs compensation is smaller.
Compensation Is Not the Same as Leaving No Trace
A Slack message being edited to "undone" rather than deleted is a telling detail. In collaborative scenarios, leaving a trace of the undo is sometimes more in line with audit and communication needs than making it disappear entirely. Teams need to decide: is the goal of compensation to restore state, or to restore state while keeping a traceable record?
Architectural Responsibility Beyond the Tool
A reverse undo tool can reduce the engineering effort of compensation, but it cannot replace architectural thinking. Which operations allow automatic compensation, how to escalate when compensation fails, and how to reconcile to discover residual side effects — these still need to be defined by the team itself. The poster's approach of looking for 5 developers to try it for free and observe where they get stuck also shows that the practical boundaries of such tools are still being explored.
Summary
Partial failure in Agent multi-step execution is essentially the consistency problem of distributed systems reappearing in AI workflows. Idempotent retries address duplicate side effects, and reverse compensation addresses side effects that have already occurred; the two are complementary, not substitutes. What you really need to think through in advance is: in your workflow, which steps cannot be taken back once executed.
Related articles
Tech FrontiersEdge AI on Microcontrollers: When Is It Actually Worth Deploying?
Drawing on Reddit discussions and Arm case studies, this article analyzes the real-world use cases for edge AI on microcontrollers: when each device needs independent inference, when a gateway or cloud is more reasonable, and the costs and boundaries of specialized hardware.
Tech FrontiersPushing the Limits of Extreme Sudoku on a 16GB GPU: Insights from Depth and Flow Matching
A researcher trained a 16.54M-parameter model on a 16GB GPU to solve extreme Sudoku, finding effective depth breaks the 60% plateau and flow matching with improved sampling pushes accuracy past 99% with ~50× lower layer-evaluation budget.
Tech FrontiersAI Agent Approval Workflows: Why Human Confirmations Always Get Mindlessly Clicked
Why do AI agent approval workflows always get mindlessly clicked? A Reddit discussion shows that separating rules from keys, low-frequency high-risk approvals, and GitHub Environments-style gates are the keys to effective approvals.