How do you stop an AI agent from deleting your data?
The short answer
Yes, if its credentials allow it. Prevent that by limiting what the agent can do, not by trusting the model: a narrow identity without delete rights, soft deletes, a dry-run plan, human sign-off on irreversible steps, and a tested rollback. If a step cannot be undone, keep it with a person.
Reviewed by Branemind engineering team. Last updated .
Why agents delete things they should not
OWASP names excessive functionality, excessive permissions and excessive autonomy as the usual root causes of Excessive Agency, the weakness that lets damaging actions follow unexpected or manipulated model output. Two of its examples apply directly to data loss. One is a read-only extension that connects with an identity that can also update, insert and delete. The other is a deletion tool that acts without asking the user to confirm.
So the failure is rarely that the model 'decided' to destroy data. It is that the system gave the model a path to do so. Anthropic's guidance adds that agents, where the model directs its own tool use, carry higher costs and the potential for compounding errors. That is why it recommends extensive testing in sandboxed environments along with guardrails.
The controls we put in place before an agent touches ERP, Tally or a customer database
- Narrow identity: the agent gets its own identity with only the permissions the job needs. OWASP says to enforce this through the database identity the extension connects with. AWS warns that a broad admin role granted for one task can spread permissions across the whole environment. A separate identity per agent also shows which agent did what and who authorized it.
- Authorization downstream: permission checks live in the ERP, database or API layer, not in the prompt. OWASP advises implementing authorization in downstream systems rather than relying on the LLM to decide whether an action is allowed.
- Soft deletes: in our builds the agent's 'delete' tool marks a record as deleted or moves it to a holding state. It does not remove it. Hard deletion is a separate step that the agent cannot call.
- Dry-run plan: before any write, the agent produces a list of the exact records and changes it intends to make. Nothing executes until that plan has been checked, by rule or by a person.
- Human sign-off on irreversible steps: OWASP recommends human-in-the-loop approval for high-impact actions. Anthropic notes that agents can pause for human feedback at checkpoints.
- Tested rollback: we run the undo path in a sandbox copy before go-live, so we know a restore works and how long it takes. A rollback that has never been run is a hope, not a control.
- Rate limits, logging and monitoring: these do not prevent excessive agency, but OWASP notes they limit the damage and give you time to notice before it becomes significant.
What to do when rollback is impossible
Some steps cannot be undone: a permanent purge, a record already synced to an outside system, a message already sent. Do not give the agent that step. Let it prepare the change and the dry-run plan, then have a named person run the action.
Treat backups the same way. In the reported TV4 case, the broadcaster denied that an AI agent deleted the edited footage and blamed a failed backup system at the production company. The edited season had to be re-edited from scratch. Whatever the cause, the lesson holds: a backup you have not restored from is not a rollback.
How to decide which steps need a human
Approving everything by hand causes review fatigue. AWS argues for letting the agent act alone where its actions can be verified and reserving human judgment for decisions that need it. Where rules cannot be stated precisely, it advises limiting access and actions, evaluating behavior, and sending genuine ambiguity to a person.
In practice, sort each action by whether it is reversible and whether a rule can check it. Reversible and checkable steps can run automatically with logging. Reversible but ambiguous steps go to a person at a checkpoint. Irreversible steps always need sign-off, or stay entirely manual. A human gate also limits damage from outside the system: Philadelphia police said their process requires human review of tips before follow-up, so an automated false submission did not bypass it.
Where this stops being true
- Soft deletes and dry runs protect the records inside your system. They do not undo side effects outside it, such as a message already sent or a payment already released.
- Approval gates stop working if they are applied to everything. Reviewers who approve in bulk are no longer reviewing, so gates belong on irreversible or ambiguous steps.
- Logging, monitoring and rate limits reduce damage but do not prevent it. They only help if someone is watching and can stop the agent.
- Rollback depends on backups that have actually been restored in a test. If that has not been done, assume rollback is not available.
The human control point
A person approves every irreversible step and decides whether to proceed when rollback is impossible. A rule cannot weigh a permanent loss against the business need, and the agent should not be the one to make that call.
Primary sources
- LLM06:2025 Excessive Agency - OWASP Gen AI Security Project
- Building Effective AI Agents \ Anthropic
- Trust in Depth: Giving agents more autonomy without losing control | Artificial Intelligence
- TV4 postpones The Challenge after backup failure forces season to be edited again | Sweden Herald
- AI submits false tip on unsolved Philly murder, police say – NBC10 Philadelphia
Related questions
Can an AI agent really delete production data?
Yes, if the identity it uses has delete permission and no confirmation step stands in the way. OWASP lists both over-broad database permissions and unconfirmed deletion tools as examples of excessive agency.
Is a prompt telling the agent not to delete enough?
No. OWASP advises enforcing authorization in downstream systems rather than relying on the LLM to decide what is allowed. Remove the permission instead of asking the model to hold back.
What should I do if an agent has already made a mistake in production?
Stop the agent by revoking its identity or access first. Then use the logs to list exactly what it changed, and restore from soft-deleted records or a tested backup. Review which permission or missing gate allowed it before you switch the agent back on.
Do I need a human to approve every agent action?
No. AWS warns that approving everything causes review fatigue. Let the agent act alone on verifiable, reversible steps and keep people for irreversible or ambiguous decisions.
How do I test a rollback?
Run the undo path in a sandboxed copy of the system before go-live, as Anthropic recommends for agents generally. Confirm that the restored data is complete and that the restore actually works.