You Can Roll Back AI Agent Code. But Can You Roll Back What the Agent Did?
Harshil Sureja
October 14, 2026
15 min read

An agent makes an incorrect change. The team deploys the previous version, restores a checkpoint, and sees normal responses again.
That can fix future behavior. It does not establish what happened to the records, messages, permissions, or external requests the agent already touched.
AI agent rollback can restore an earlier deployment or supported internal state. Recovering the agent’s external effects is a separate task: establish what happened, determine what can be corrected, and verify the resulting business state.
A deployment can be restored while an unwanted access grant remains active. A checkpoint can be replayed while a request from the original run is still processing. A correction can restore a record without undoing what a recipient already learned from a message.
For teams building action-taking agents, the useful question is: What evidence and controls let us recover each action without creating another incident?
What AI agent rollback can restore
The word rollback can describe several different operations. Give each one a defined scope.
| Recovery layer | What it addresses | What it does not establish |
|---|---|---|
| Deployment and configuration | Application code, prompts, tool definitions, model settings, and policies | That earlier external effects have been corrected |
| Internal execution state | Supported checkpoints, pending steps, saved context, and workflow progress | That external systems match the restored checkpoint |
| Business effects | Records, access grants, reservations, messages, and third-party actions | That every effect is reversible or that prior circumstances can be recreated |
Agent rollback should name the layer being changed. “We restored version one” is a deployment statement. “We verified and corrected the affected access grants” is a business-recovery statement.
Some operations can be reversed within a transaction before it commits. Once a workflow has committed changes across separate systems, a local database rollback does not automatically reverse the whole sequence.
Microsoft’s compensating-transaction guidance describes application-specific recovery for such workflows, including the possibility that other actors have changed the data in the meantime.
Why restoring a checkpoint can repeat the damage
Checkpoints record progress in the system that manages the agent. They are useful for inspection and resumption, but are not automatically transaction boundaries for every connected service.
LangGraph’s time-travel documentation explains that replay resumes from a prior checkpoint and re-executes later nodes, including model calls and API requests. Those calls may produce different results. Forking creates a new branch rather than erasing the original execution history.
If a later node sends a message or creates a record, replay can issue that operation again unless the action boundary handles repetition safely.
The approval path also matters. LangGraph’s interrupt guidance notes that resuming an interrupted node can rerun earlier side effects within that node.
Practical implication: Before replaying, identify which steps will execute, which external actions may already have completed, and how repeated execution is controlled. Use a suitable test environment or non-mutating simulation when investigating alternative paths.
Do not assume the same behavior across frameworks. Check what your implementation restores, caches, reruns, and retains.
AI agent versioning needs a compatibility plan
A Git revision alone may not identify the system that produced an action. The runtime can also depend on prompts, model configuration, tool schemas, retrieval settings, policy versions, and stored state.
Record the relevant release configuration and the evidence associated with each consequential action. Version references should be sufficient to identify what ran without copying unnecessary sensitive information into logs.
Then check whether the proposed earlier version can operate on the state that now exists. A newer release may have changed a checkpoint schema, a tool response, or a workflow’s expected sequence.
Temporal’s workflow-versioning documentation makes this compatibility issue explicit for its replay-based execution model: changes to workflow orchestration need appropriate versioning to preserve replay safety.
For AI agent versioning, decide how new, running, paused, and queued executions are handled during a deployment change. You may need to retain compatible workers, migrate supported state, or reconcile a run before starting a new execution.
An earlier configuration is a recovery candidate, not proof that it is safer. Validate the relevant failure path and compatibility before resuming affected work.
Classify the action before choosing a recovery operation
Some actions are restorable under specific conditions. Others can be compensated, canceled while pending, or only contained after completion.
| Action and condition | Possible response | Important limitation |
|---|---|---|
| Record updated; previous value and current version are known | Apply a conditional correction | A later legitimate edit may make restoring the old value wrong |
| Reservation still pending and the provider supports cancellation | Cancel the identified reservation | Cancellation may be unavailable after a defined transition |
| Committed business operation has an approved corrective counterpart | Execute a compensating operation | Compensation is a new action with its own rules and failure risks |
| File deleted and a suitable recovery copy exists | Restore the selected data through the established recovery process | Backup coverage, dependencies, and later changes determine what can be restored |
| Message already delivered or information already disclosed | Contain further exposure and address consequences | Deleting a local copy cannot make information unseen |
| Request timed out and the remote result is unknown | Reconcile using operation identifiers and external evidence | A timeout does not establish that nothing happened |
This is a review aid, not a universal classification supplied by every provider.
Define recovery for the particular action and state. A method named undo does not establish that its implementation preserves current business rules or legitimate work.
Treat an unknown outcome as a first-class state
Suppose a remote service applies an update, but the response is lost. The agent records an error. If the error is treated as proof of no effect, a retry can duplicate the operation or overwrite a subsequent change.
Distinguish at least these situations:
- The operation was never dispatched.
- It was rejected with evidence that no effect occurred.
- It was dispatched, but the outcome is unresolved.
- It completed, with evidence identifying the effect.
- It completed incorrectly or partially and needs a recovery decision.
These are suggested application states. Adapt them to the provider’s actual response and consistency semantics.
Reconcile an uncertain request through its operation or provider identifier, event evidence, and authoritative records. A current record with the expected value may not prove that this particular request created it. Likewise, an immediate empty query may be inconclusive if the service is still processing or its read path is eventually consistent.
When the available interface cannot establish the result, retain the uncertainty and use the defined escalation path. Inventing a definite failure status makes later recovery harder.
Give each intended operation a stable identity
Idempotency means repeated execution of the same operation does not add effects beyond its intended initial effect. It helps prevent duplicates; it does not make a wrong action correct.
AWS’s guidance on idempotent APIs describes caller-provided identifiers that express operation intent and support safe retries.
Keep the intended operation’s identity stable across attempts. Do not create a new business-operation key simply because a model generates a new plan, the worker restarts, or a checkpoint is replayed.
Also distinguish repetition from a genuinely new request. Reject or review conflicting parameters under the same identity instead of silently treating them as equivalent.
Provider contracts matter. Stripe’s API v1 idempotency documentation explains that a reused key can become a new request after the original key has been pruned. Check the scope, retention, and behavior of the specific endpoint you use.
Practical implication: Test delayed retries and replay after the provider’s deduplication window. A key stored in your database is not an unlimited external guarantee.
Record enough evidence to reconstruct and repair the action
An agent transcript explains the interaction. Recovery also needs records that connect the intended operation to its actual effect.
For AI agent state management, distinguish internal progress from externally confirmed outcomes. Preserve the execution history as evidence instead of replacing it with the hoped-for recovered state.
| Evidence | Recovery purpose |
|---|---|
| Workflow, step, operation, and attempt identifiers | Distinguish one intended action from its retries |
| Target account or tenant, resource, and relevant version | Identify the affected customer context and object, and detect conflicts |
| Intended change and preconditions | Establish what should have happened |
| Caller, authorization, and applicable approval references | Check whether the action was permitted |
| Release and policy identifiers | Identify the configuration that produced the action |
| Dispatch status, timestamps, provider IDs, and returned evidence | Separate intent from confirmed or uncertain effects |
| Recovery decision, owner, and corrective-operation identity | Track what was approved and attempted afterward |
| Verification result and unresolved consequences | Establish whether the business outcome is acceptable |
Retain necessary payloads in appropriate protected storage or use secure references. Minimize sensitive data in broadly accessible telemetry and define access and retention requirements.
Record the intent before dispatch and update the history as evidence arrives. That narrows the visibility gap, but does not make a local log and an external API call one atomic transaction. A crash can still leave an unresolved result.
For event-driven designs, the transactional outbox pattern can address a database-and-message dual write. AWS also notes that consumers must handle possible duplicate delivery. An outbox does not make every downstream effect globally reversible or exactly once.
AI compensating transactions are business repairs, not time travel
AI compensating transactions apply established compensation patterns to operations performed through an AI workflow. The business-specific corrective action should be defined and controlled, rather than improvised as unrestricted model-generated instructions.
Compensation may release a reservation, correct a permitted field, or revoke an unwanted grant. It does not necessarily restore the exact original world.
For a multi-step process, the saga pattern coordinates local transactions and compensating work. Concurrent changes still need to be considered; recovery is not permission to overwrite another actor’s valid work.
Design each corrective operation with:
- A reference to the original effect.
- Current-state and business-rule checks.
- Explicit authority and approval requirements.
- Its own stable identity and safe-repeat behavior.
- A verified result or a defined unresolved state.
The compensation’s identifier should be distinct from the original forward-operation identity while remaining linked to it.
Timing matters. Temporal’s compensation guidance shows why recording compensation only after a remote call returns can miss an effect that occurred before a timeout or crash. Plan the recovery information before issuing the consequential operation, including how to handle the possibility that it never completed.
A worked example: recover onboarding without deleting legitimate work
Consider a hypothetical SaaS onboarding agent authorized to create a team workspace and invite a person with the member role.
It creates the workspace, grants the owner role incorrectly, sends the invitation, and attempts to update a CRM record. The CRM request times out. Before the incident is diagnosed, the invited person joins and creates a valid project.
The operator restores the previous deployment. That does not resolve the role grant, delivered invitation, uncertain CRM result, or later project creation.
These events are invented for illustration. They are not a Devine Globe client incident.
Build an action-by-action recovery decision
| Observed situation | Recovery question | Candidate response to verify |
|---|---|---|
| Workspace creation is confirmed | Is the workspace itself valid, and does it contain later legitimate work? | Retain it unless the reviewed business decision requires a different response |
| Owner role was granted instead of member | What role is currently authorized, and has a legitimate later change occurred? | Correct the specific grant through the authorized access-control path |
| Invitation was delivered | Does the link or invitation still enable unwanted access? | Address the access path; handle any necessary communication separately |
| CRM update result is unknown | Can request-specific evidence establish whether it committed? | Reconcile before retrying or applying a correction |
| A legitimate project was created afterward | Would broad restoration or deletion destroy valid work? | Preserve it and limit the repair to affected resources or fields |
| Older queued attempts still exist | Can they repeat the grant after the correction? | Contain or invalidate the affected work before resuming |
Correcting the role does not establish that the unintended authority was never used. Review available evidence of its use and follow the relevant incident process if further effects occurred.
A whole-workspace delete might appear to reverse onboarding, but it could remove work that should remain. The recovery goal is the reviewed valid business state, not necessarily a snapshot of the moment before onboarding began.
Make the uncertainty visible
For the timed-out CRM request, a useful action history might contain an operation ID, the attempted record and change, the dispatch time, and an unresolved outcome.
The recovery owner looks for provider or audit evidence tied to that operation. If it confirms success, the next question is whether the committed change is correct. If it confirms no effect, a controlled retry may be appropriate. If it remains unknown, the workflow stays under the defined review process.
Returning the agent to an old checkpoint would not supply that missing evidence. It could simply attempt the CRM write again.
A practical AI agent recovery sequence
Recovery should follow the system’s incident procedures and the consequences of the affected action. This sequence is a planning structure, not a promise that every case can be automated.
1. Contain the affected execution paths
Stop new affected work where appropriate, restrict relevant write-capable tools, and inspect queued tasks, running workers, callbacks, and retries. Pausing a user interface or restoring a deployment does not necessarily stop already dispatched operations.
Use the narrowest containment that adequately addresses the incident. Preserve unaffected workflows where possible, and preserve evidence needed to investigate.
2. Establish the affected actions and their results
Identify the time window, release, workflows, and resources involved. Classify each operation as confirmed, rejected without effect, not dispatched, or unresolved according to the available evidence.
Check external records and operation receipts rather than treating the agent’s final message as confirmation.
3. Select a compatible runtime and a valid recovery plan
Determine whether rollback, a forward fix, or temporary disabling is appropriate. Confirm compatibility with saved state and current interfaces.
For each effect, decide whether to retry, cancel, correct, compensate, retain, or escalate. Account for current rules and legitimate subsequent changes. Use conditional writes or another suitable concurrency mechanism when a repair depends on an expected record version.
4. Execute and track the approved repairs
Keep recovery authority constrained. Required human decisions should apply to concrete actions and evidence, not a broad instruction to “undo everything.”
OWASP’s excessive-agency guidance recommends downstream authorization, minimum necessary privileges, and approval for high-impact actions. Recovery operations need these controls too.
If a corrective action fails or times out, track its result as another operation with its own recovery path. Do not repeatedly invoke it without checking whether it already took effect.
5. Verify before resuming
Check the repaired business state, unresolved operations, access, and retained legitimate work. Confirm that queued or stale work cannot reintroduce the problem.
Microsoft’s agentic behavior guidance emphasizes current authorization and authoritative evidence. Restoring older memory should not restore revoked access or make an expired approval valid.
Resume through an appropriate limited rollout with explicit acceptance criteria. Preserve the original action history and link it to repairs rather than concealing the incident through a rewritten success status.
Test AI agent failure recovery at the awkward boundaries
The most useful recovery tests exercise points where local progress and external effects can diverge.
| Injected situation | What the test should establish |
|---|---|
| Remote action succeeds, but its response is lost | The result remains reconcilable without duplicating the effect |
| Worker crashes after dispatch and before recording confirmation | The operation can be located through durable identity and external evidence |
| An earlier checkpoint is replayed | Re-executed calls respect the action’s repeat and authorization rules |
| A resumed node reruns code before an approval interrupt | No premature or duplicate consequential action occurs |
| A callback arrives after recovery began | Stale completion cannot resume invalid work |
| Another actor changes the record before compensation | A conflicting repair preserves legitimate work or enters review |
| Compensation takes effect, but its response times out | Retrying the correction does not create a second unwanted effect |
| Earlier code receives a newer saved-state shape | Compatibility is established or the run is stopped for an explicit migration path |
| Authorization changes while a run is paused | Resumption uses current authority rather than cached assumptions |
Use isolated or otherwise controlled environments for failure injection. Test the provider behavior your implementation depends on, including idempotency windows and supported cancellation states.
AI agent failure recovery is successful when the resulting state meets the agreed requirements. Passing a restart test only establishes that execution restarted.
Measure recovery beyond service uptime
An endpoint can be healthy while incorrect permissions, records, or unresolved requests remain.
Google Cloud’s agent-observability guidance covers execution paths, tool behavior, resource use, safety, and quality alongside application health.
For recovery, useful measures include time to contain affected actions, the number of unresolved outcomes, time to verify consequential repairs, correction failures, repeat incidents after resumption, and unintended changes caused by the repair itself.
Define measures by action type and impact. A delivered notification and an incorrect permission grant need different completion evidence. Do not count a dispatched compensation command as a verified repair while the downstream result is still pending.
Related Blogs
.2qinst50l_1uj.png)
Partner with us and unlock the future of your business!

Still have questions? Book a call with our friendly team to get all your questions and queries answered.
Schedule a callFAQ
Solving your confusions right away!
Explore How We Turn Client Challenges into Triumphs Across Diverse Sectors with Cutting-Edge Technologies.
CONTACT US
Have a project in mind? Discuss with us
Explore How We Turn Client Challenges into Triumphs Across Diverse Sectors with Cutting-Edge Technologies.

"Devine Globe team helped us turn our idea into a working product faster than we expected."



