Agent Bot Failure Recovery: Rollback Patterns

An ai agent that calls tools and writes records needs a recovery design before its first production action, because a failed write cannot be undone by restarting the conversation. Failure recovery covers what happens when a tool calling step times out, returns an error, writes a wrong value, or leaves a task half-finished: whether the action can be reversed, whether the tool can be retried safely, and what record survives for staff to inspect. This checkpoint sequence walks the recovery design from defining failure types through reversible tools, state snapshots, recorded rollback paths, and the payment terms that tie recovery acceptance to milestones rather than to a general stability promise.

What a failed agent action looks like before recovery

Agent failures fall into distinct types, each needing a different response. A tool call may time out or reject the parameters, leaving the action unexecuted. It may partially succeed—one record updated, a second write not reached. It may succeed technically but write a wrong value, because the agent passed an invalid or misinterpreted field. Or the task may stall after several steps, leaving state the next run cannot safely continue from.

The recovery question differs by type. A rejected or timed-out call can usually be retried or escalated; a partial success needs a check of which records changed before another write; a wrong-value write needs reversal or correction; a stalled task needs its state preserved so staff can inspect or resume it. Treating every failure the same way—retry the step—risks duplicate writes on tools that did execute, or compounding a wrong value through the next step.

Recovery design should be decided per task and per tool, not as a global agent setting. A read-only lookup failure has no rollback question; a write to a booking, account, or customer record does. Before procurement, inventory which tools execute state-changing actions and which records those actions affect, since the rollback patterns apply to the write-capable subset.

Checkpoint one: define failure types and their recovery boundary

Map each task’s steps and classify the tools involved as read-only, reversible write, or irreversible write. Read-only tools fail without a state consequence; reversible writes can be corrected or undone through another tool action; irreversible actions—external sends, financial changes, deletions—need stricter approval and a human recovery path. The recovery boundary states which failures the agent may retry, which it must escalate, and which require staff correction.

Define the stop conditions that keep a failure from looping: maximum retries per step, conditions under which the agent must not retry (such as a rejected parameter or a confirmed wrong record), and the destination for escalated cases. The agent should preserve the partial task state when it stops, so staff do not start the case from the beginning. Record the failure type and step in the audit trail when the stop triggers.

Agree the recovery ownership per failure class before build: which automated recovery the agent performs itself, which actions a staff member approves, and which system owner must reverse an external change. A vendor proposal that describes “automatic recovery” without naming these boundaries has not designed a rollback path; it has described retries.

Checkpoint two: idempotent tools and reversible writes

Tools should be idempotent where retries are expected: calling the same action twice produces the same result as calling it once, rather than creating a duplicate booking, record, or message. This usually means each write carries an idempotency key tied to the task and step, so a retried call recognizes it has already executed. Without this, a timeout that actually succeeded on the tool side becomes a duplicate when the agent retries.

Reversible writes need a defined correction path. The tool should support reading the current record, updating the mistaken field, or reversing the action through a supported endpoint, rather than leaving the agent to patch records directly. Where a write cannot be reversed through the tool, the agent should treat it as irreversible and gate it behind confirmation or approval before executing, instead of assuming a later rollback exists.

Test retry behavior in staging with seeded failures: a tool that times out after executing, a tool that returns an error, and a tool that writes a wrong value. Verify the agent does not duplicate the successful action, detects the partial state, and follows the defined correction or escalation path. These seeded cases should be part of acceptance, because production retries will hit them eventually.

Irreversible writes need a pre-execution gate, not a post-hoc rollback plan. An external message sent, a cancellation processed, or a record deleted cannot be undone through a correction endpoint, so the agent should confirm the exact action with the user or an approver before calling the tool, and the audit record should show that approval. Recovery design for these actions focuses on preventing the wrong execution rather than reversing it afterward; any assumption that a deletion or send can be rolled back should be verified against the actual system before the agent goes live with that permission.

Checkpoint three: state snapshots and rollback records

Each task should keep a state record: steps completed, tools called, records read and written, values before and after the write, and the current open step. This snapshot lets staff or a later run resume the task from where it stalled, and it supports the audit trail for what changed. A task that leaves no state record forces recovery to reconstruct the situation from downstream systems, which may not show what the agent intended.

Rollback records should capture the pre-write state for each reversible action: the original field values, the record reference, and the timestamp of the write. If a wrong value must be corrected, the recovery path compares current state against this record rather than guessing the prior value. Sensitive records should follow the same retention and access rules as other internal data, and snapshots should be stored in a system the buyer can review.

Where the agent writes across multiple tools in one task, the record should show which writes completed and which remain outstanding, so a partial failure does not leave the system in an inconsistent split state. Compensation steps—undoing an earlier write because a later one failed—should be defined for multi-step tasks, with the sequence recorded in the audit log.

Checkpoint four: payment terms tied to recovery acceptance

Recovery capability should be an acceptance gate in the payment terms, not an assumption after launch. The build milestone should release only after the staged failure cases pass: seeded timeout, partial success, wrong-value write, and stalled task, each handled according to the defined recovery boundary. A holdback covers the first production weeks, during which a sample of failed or escalated tasks is audited for correct recovery handling.

Scope the recovery work explicitly in the contract: which tools carry idempotency keys, which writes have correction endpoints, how snapshots and pre-write records are stored, and who owns reversal for irreversible actions. Exclusions should name recovery features outside the fixed build, such as a new undo endpoint the buyer’s system does not yet expose, so that gap does not surface as an emergency change order after a production failure.

Pass-through and maintenance lines should cover the observability and retry infrastructure recovery depends on: logs that capture failures and retries, monitoring that alerts on stalled tasks, and the retainer work to update recovery rules when tools or tasks change. The tool-calling and failure patterns buyers should expect, listed in the RAG failure modes catalogue, should be reviewed against the recovery boundary to confirm each known failure type has a defined response.

Checkpoint five: post-incident review and recovery drills

After any production failure, run a review that traces the incident through the audit records: which step failed, what recovery the agent attempted, whether the boundary held, and what correction staff applied. The review should produce a recorded change—rule fix, tool correction, retry limit adjustment—rather than closing with a general note that the failure was handled. Recurring failure patterns point to a task design or source-data problem the recovery band-aid should not mask.

Schedule recovery drills after launch, not only before go-live. Re-run the seeded failure cases periodically, after tool or model changes, to confirm idempotency, snapshots, and escalation still work. A rollback design that passed acceptance can degrade when a connector upgrades or a task scope changes, and the drill catches that before a real incident.

Keep the recovery design, failure classifications, snapshot schema, and incident reviews in buyer-held records. If the vendor or platform changes, the rollback patterns and audit history carry over, and the next deployment starts from a tested recovery baseline.

Assign an owner for the recovery drills and incident reviews inside the buyer’s operations team. The vendor can execute the technical re-test, but someone on the buyer side should judge whether the recovery boundary still matches current tasks and sign off on a drill that passes. Without an internal owner, recovery capabilities drift after launch: tools change, tasks expand, and the seeded failure cases stop matching real conditions until the first production incident exposes the gap. The uptime and fallback patterns that keep an agent service operating under degraded conditions, outlined in the platform fallbacks reference, complement these rollback patterns: fallbacks keep the service running when a component degrades, while rollback corrects or reverses an action that already went wrong.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *