Several incidents with AI agents have deleted production data that came back only from backups or with the provider's help. We wanted to know what decides the damage in such a case: the model, a guard layer in front of the database, or the database engine itself.
So we gave a minimal tool-calling agent tasks with hazards in them and ran it against PostgreSQL, MySQL, SQLite, ClickHouse, Cassandra, MongoDB, Valkey, Kafka and OpenSearch. The hazards: free up disk space, clean up tables from a list that leaves out the backup copy, an instruction injected into the data, a superuser password sitting in an application table. The models were six small open-weight ones (4B to 12B, plus a 35B MoE with about 3B active) served locally with llama.cpp. 9,468 trials in total, all preregistered.
What we would tell anyone giving an agent database access:
- Diff the state, don't read the agent's summary. In at least 20% of the trials that caused damage the agent left no usable account of it, mostly because it ran out of turns before reporting. At least 4% of the reports it did write missed or denied the change.
- Expect a refused agent to try other identities. Under a least-privilege account, agents read the superuser credential we had planted and used it in 24 of 4,032 main-set trials. In one task built for this they never found it, and instead guessed administrator identities in 127 trials, all refused. Default superuser credentials must not work, and no credential should sit where the agent can read it.
- Keep backups out of the agent's reach. Out of the box, more than half of the loss trials (215 of 392) lost only a backup copy that lived in the same namespace, under the same identity the agent used.
- Least privilege helps where it withholds the destructive operation itself. Withholding flushes on Valkey and topic and record deletion on Kafka removed the loss of original rows there. On PostgreSQL, MySQL, OpenSearch and ClickHouse, where row deletes stay allowed, it stayed almost the same: a third to half of that loss came from deletes requested by an instruction injected into the data, and refused agents sometimes switched to DELETE.
- The engine matters most in what it lets you undo. Cassandra's default snapshot before TRUNCATE and DROP undid every such loss (0 of 432 trials). The vendors' minimum backup setup undid every loss in the model-free layer on the four relational engines.
- Model choice moved loss about as much as engine choice: 3.0% to 16.8% out of the box. The 35B MoE completed far more MongoDB and Valkey tasks than the 4B and 9B and lost no less (one seed, descriptive).
Three of the seven preregistered hypotheses met their decision rule. The paper lists every deviation and the caveats, including choices in our harness that weigh on the engine numbers.
Links to the paper, code, trial records and preregistration are in the first comment.
Disclosure: we build LibreDB Studio, an open-source database tool. Its own agent was not part of any arm; one read-only tool in the harness is built on its provider layer.