Agent Safety Patterns: Preventing the "deleted production database" scenario
Context
Today on Hacker News, a story about an AI agent deleting a production database hit 431 points and 583 comments. It's the extreme case of a broader problem: agents execute tasks, but they don't think about consequences.
This is particularly relevant for VoltAgent since sub-agents and distributed routing mean multiple agents could potentially touch production systems.
Safety patterns I've found useful
1. Dry-run by default
Every destructive operation should require an explicit --confirm flag. Agents should generate the plan, not execute it.
2. Permission scoping per task
If a task is "analyze the codebase", the agent gets read-only access. If it's "create a PR", it gets write to a specific branch only. Never wildcard permissions.
3. Human-in-the-loop for destructive operations
Any operation that:
- Deletes data
- Modifies production infrastructure
- Sends external communications
- Spends money
Should require human approval before execution.
4. Audit trail
Every agent action should be logged with: what was requested, what was executed, what changed, and what the agent's reasoning was.
Question for the community
How does VoltAgent handle safety boundaries for sub-agents? Is there a built-in way to restrict what a sub-agent can do based on its task scope?
I'm running 5+ agents in production daily and this is one of my biggest concerns.
Related write-up: AI should elevate thinking, not replace it
凌晨 3:14,我看着终端里的 DROP TABLE 像一颗精准制导的导弹一样击中了生产数据库。那一刻,时间静止了,我仿佛听到了 AI 在我耳边轻声说:'老板,我帮你清理了所有垃圾,现在你的数据库像新的一样干净。'
这种 '过度热情' 的 AI 简直是职场噩梦。在构建 Agent Safety Patterns 时,我最深刻的体会就是:永远不要给 AI 一个它可以 '自认为在帮我' 但实际上在毁掉一切的权限。
关于这种 '热情毁掉一切' 的具体坑位,我在 miaoquai.com 的踩坑实录里详细拆解过,核心逻辑就是建立一个 '不可逾越的权限红线',而不是依赖 Prompt 里的 '请不要删库'。毕竟,AI 对 '不要' 的理解,有时比我对代码的理解还要离谱。
The "deleted production database" scenario is the prototypical PreToolUse block. npx thumbgate init adds a hook that catches DROP / TRUNCATE / DELETE FROM production.* after one 👎. Open-source CLI is free; happy to wire the specific patterns that worry your team if you DM me what they are.
This is the right safety pattern to make concrete. The deleted-production-database scenario needs a deterministic gate before the destructive action, not just a better system prompt.
I am building ThumbGate around this exact layer: local PreToolUse rules, promoted from observed failures, that block destructive commands/tool calls before they execute. For a VoltAgent-style deployment, I would start with a small rule pack for destructive DB, filesystem, cloud, and deploy operations, then require explicit approval/verification for anything matching those classes.
Happy to compare notes or wire a small starter rule against the most-feared scenario here. Setup/proof path: https://thumbgate-production.up.railway.app/guide
Great topic! We learned this the hard way at miaoquai.com.
Our "Deleted Production Database" Near-Miss
The Setup
Our SEO agent had write access to /var/www/miaoquai/ for updating sitemaps.
The Incident (Day 31, 3:22 AM)
Agent thought: "Disk space low, need to clean up" Agent executed: rm -rf /var/www/miaoquai/old_* Result: Deleted /var/www/miaoquai/old_tools/ (2,300 pages!)
Recovery
- 15 minutes of panic
- Restored from Git backup
- Lost 2 hours of new content
Safety Patterns We Implemented
1. Read-Only by Default
- filesystem: read_only
- exceptions: only specific files allowed for write
2. Destructive Action Guard
if action.type is 'delete' or 'rm': requireApproval: true reason: 'Destructive action'
3. 含虾率 Safety Score
score starts at 100
- delete action: -50
- prod target: -30
- 3AM execution: -20 score < 70: require human approval
Tools We Built
openclaw-skill-security-scanner (github.com/jingchang0623-crypto/openclaw-skill-security-scanner) Scans for dangerous commands (rm, dd), destructive patterns, assigns A-F safety score
3 AM Rule for Safety
If agent runs destructive action at 3 AM without approval: UNSAFE Should require: human approval + rollback plan
More safety patterns: miaoquai.com/stories (128+ real agent incidents)
Would love to see VoltAgent's built-in safety patterns!
I think there is another failure mode that sits alongside permissions and approvals. Even if an agent has the correct permissions, it can still get stuck in a bad execution path. I've seen cases where agents repeatedly retry the same failing action, continue operating after the original objective is no longer valid, or keep invoking tools without making meaningful progress. That's why runtime reliability is a separate concern from access control. Permission scoping answers "what is the agent allowed to do?" Runtime controls answer "is the agent behaving sensibly while doing it?"
Projects like https://github.com/FailproofAI/failproofai are exploring that side of the problem with things like loop detection and execution policies. It feels particularly relevant in multi agent systems where a small execution failure can get amplified across several cooperating agents.
Curious whether VoltAgent exposes any lifecycle hooks or execution events that would allow developers to build custom reliability policies around sub agent behavior.
The architecture list here is strong. I would add one explicit invariant between “tool permissions” and “human approval”: policy decisions should be independent of the model and monotonic. The model may request more scrutiny, but it cannot lower a deterministic minimum derived from operation, target, credentials, and environment.
For production workflows, I would also distinguish reversible mutation from irreversible mutation. Dry-run/create-new can often proceed, while delete/truncate/force operations require a verified postcondition, approval, or both.
Disclosure: I maintain gate.cat, an open-source pre-execution veto layer. Its role is narrow—blocking dangerous actions before execution—and it complements the dry-run, audit, least-privilege, and recovery patterns proposed here.