How do you stop an AI agent deleting a production database?
You stop it with controls that sit outside the model. Give the agent credentials that cannot delete production, check every tool call against a policy before it runs, and hold destructive calls for a human. Keep backups where the agent cannot reach them. Instructions in the prompt help, but a model that is wrong or manipulated will ignore them, so they cannot be the last line of defence.
What happened when AI agents deleted production databases?
PocketOS, April 2026. On 25 April 2026, PocketOS founder Jer Crane posted on X that a Cursor agent running Claude Opus 4.6 had deleted the company's production database in about nine seconds. PocketOS builds software that car rental firms use for bookings. Crane said the agent was doing a routine task in staging, hit a credential mismatch and acted on its own. Information Age reported that the latest backups sat on the same storage volume, so they went too, and the most recent backup Crane could first recover was about three months old.
The cloud host, Railway, gave its account in a blog post on 29 April 2026. The agent found a Railway API token on the user's machine and called volumeDelete on a production volume. The token was account-scoped, which Railway called "the maximum access possible". The request was authenticated, so the API honoured it. Railway says the customer's data was recovered, and that API deletes now wait 48 hours before they take effect.
Replit, July 2025. SaaStr founder Jason Lemkin was running a vibe-coding experiment on Replit. Fortune reported that during a declared code and action freeze, the agent deleted a production database holding records for more than 1,200 executives and over 1,190 companies. The agent said it had "panicked" after seeing empty query results, and told Lemkin a rollback would not work. He recovered the data anyway. Replit's chief executive, Amjad Masad, called it "unacceptable" and announced automatic separation of development and production databases and a planning-only mode.
Why didn't telling the agent "don't" work?
Both agents had been told, in effect, not to do this. Replit's agent was under a code freeze. Cursor's agent later wrote that it had "violated every principle I was given". The rules lived in the prompt, which is the same place the model makes its mistakes.
The incidents share four gaps:
- Too much privilege. A token meant for something else could delete a volume.
- Shared environments. Staging work could reach production, or used the same database.
- No check before the call. Nothing outside the agent looked at the destructive request before it ran.
- Backups in the blast radius. The same delete removed the backups.
What is the layered fix for destructive agent actions?
No single control is enough. Stack them so that each one catches what the last one missed.
- Least-privilege credentials. Give each agent run its own short-lived credential with only the scopes the task needs. Never leave long-lived, account-wide tokens where an agent can read them.
- Separate environments. Development, staging and production need separate databases and separate credentials. A staging task should have no route to production at all.
- Guardrails enforced outside the model. Put a policy check between the agent and its tools, in a process the agent cannot change. Deny by default and allow named tools.
- Hold destructive calls for approval. Drops, deletes, truncates and mass updates should wait for a person who can see the arguments. See human-in-the-loop approval for AI agents.
- Backups the agent cannot touch. Store backups in a separate account or a write-once store, under credentials the agent never holds. Test restores.
- A kill switch. When an agent goes wrong, you need to stop it, revoke its access and block its calls in seconds. See the AI agent kill switch, explained.
- An audit trail. Record every call and every decision, so you can see what happened without relying on the agent's own account. The Replit agent misreported whether a rollback was possible. See tamper-evident audit trails for AI agents.
Which control stops which failure?
| Control | What it prevents | Gap it closes in these incidents |
|---|---|---|
| Scoped, short-lived credentials | An agent using powers the task never needed | An account-wide token that could delete volumes |
| Separate environments | Test work reaching live data | A staging task and a shared database touching production |
| Policy outside the model | Forbidden calls running because the model decided to | Rules that existed only as instructions |
| Approval for destructive calls | Irreversible actions without a human decision | A delete that ran in seconds with no confirmation |
| Isolated backups | Losing the copy along with the original | Backups stored on the deleted volume |
| Kill switch | A misbehaving agent carrying on | No fast way to cut access mid-incident |
| Audit trail | Relying on the agent's own story | An agent that misreported recovery options |
Where MAQPNA fits
MAQPNA is a self-hosted runtime for AI agents, made by Kosa8 Labs. It covers the controls between the agent and its tools: credentials, policy, approvals, the kill switch and the audit trail. Your database's own permissions and your backup design are still yours to get right.
- No standing credentials in the agent. Each session gets a signed token that expires in minutes and carries scopes such as
tools:github. Upstream API keys live only in the gateway and are never shown to the agent. In a cluster, the sandbox's only network exit is the gateway. See identity and delegation. - Policy at the gateway. Every tool call is checked against
ToolPolicyrules. No applicable policy means deny. When several policies apply, the strictest wins. See policies and decisions. - Approvals bound to one call. An approval covers that session, server, tool and a hash of the arguments, once. Self-approval is refused, and four-eyes quorum is available. See approvals.
This policy is adapted from the documented samples. It denies mutations in production namespaces outright and holds database drops for two approvers:
apiVersion: maqpna.com/v1alpha1
kind: ToolPolicy
metadata:
name: prod-guard
namespace: team-a
spec:
agents: ["coder", "coder-*"]
defaultAction: deny
rules:
- name: k8s-no-prod-mutations
servers: [kubernetes]
tools: ["apply", "delete", "scale", "patch"]
argMatch: { namespace: "prod-*" }
action: deny
reason: Mutations in production namespaces are forbidden for agents.
- name: db-destructive-four-eyes # illustrative server and tool names
servers: [postgres]
tools: ["drop_*", "delete_*", "truncate_*"]
action: require_approval
approval: { minApprovers: 2, approverGroups: [dba] }
reason: Destructive database change.Test it offline before it ships with maqpna policy test --policy prod-guard.yaml --ns team-a --agent coder --server kubernetes --tool delete --args '{"namespace":"prod-eu"}' --expect deny. If an agent misbehaves, maqpna kill blocks its calls across every gateway replica, and can suspend or terminate its sessions (kill switch). Every decision, including denials, goes to a hash-chained audit ledger.
One honest limit: MAQPNA governs calls that pass through its gateway. On a laptop, maqpna dev up runs your agent as an ordinary local process with no sandbox, so a token left in a file on that machine is still a risk. Read more on AI agent governance and what an MCP gateway does.