How to Configure CrewAI CockroachDB Prevent Delete
To set up crewai cockroachdb prevent delete controls, you must restrict the database user role. You revoke delete permissions on your tables before the agent connects to the database. Most engineering teams start by giving their AI agents a shared database user. When that role has broad permissions, one bad prompt can wipe out production rows. A safe setup requires strict database roles and clear boundaries on agent tools. How to set up crewai cockroachdb prevent delete rules CrewAI lets you
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
To set up crewai cockroachdb prevent delete controls, you must restrict the database user role. You revoke delete permissions on your tables before the agent connects to the database. Most engineering teams start by giving their AI agents a shared database user. When that role has broad permissions, one bad prompt can wipe out production rows. A safe setup requires strict database roles and clear boundaries on agent tools.
How to set up crewai cockroachdb prevent delete rules
CrewAI lets you build teams of AI agents that work together on tasks. Each agent can use tools to read data, run calculations, or call external services. When an agent needs database facts, developers give it a SQL tool. This tool takes a question from the agent and turns it into a query. Then the tool runs that SQL statement against your CockroachDB cluster.
Running generated SQL queries is always a security risk for any team. To prevent row deletion, you must change how the agent logs in. You create a dedicated role inside CockroachDB just for your CrewAI app. You grant this role permission to read tables and maybe insert new rows. You do not grant the delete privilege on any schema or table. If the AI agent writes a delete statement, the database rejects the command right away.
You can also split agent tasks across different database roles. One agent in your crew might only read customer records for a report. That agent gets a read-only database login. Another agent might need to add new log entries after a task finishes. That second agent gets a role that can only insert rows into one table. Neither agent gets the power to remove rows or drop tables.
What native database roles solve and what they miss
Database privileges are your first line of defense against bad agent behavior. They set hard rules at the storage level. Even if a user tricks the AI model, the database role blocks the delete command. This setup stops full table wipes and keeps your core records safe. It also helps your team pass basic security reviews without changing your app code.
Still, static database roles only decide who can log in and run broad command types. They do not inspect what individual statements do while they run in flight. For example, an agent might need update permissions to fix customer status flags. With update rights, a confused agent could still overwrite every row with blank values. To the database, that bad update looks completely valid and passes the role check.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static roles also create extra work when you manage secrets across many agents. Every agent tool needs a database password or key stored in its environment. When you share one role across a crew, your database logs show one generic user. You cannot tell which specific task or user prompt triggered a bad query. Also, native roles do not mask sensitive data in query results. If an agent reads a customer table, the query returns raw emails, phone numbers, and card numbers.
Why prompt rules cannot replace real database controls
Many developers try to stop deletions by adding rules to the agent system prompt. You might tell the CrewAI agent to never run a delete or drop command. This approach helps guide the model during normal tasks, but it is not a security boundary. Large language models do not follow instructions every single time they run.
When an agent reads untrusted text from a ticket or email, it faces prompt injection risks. Hidden instructions in that text can tell the model to ignore its original rules. The agent might then generate a destructive query and send it to the database tool. Because the tool just passes text to the database, only strict role limits or statement checks can stop the damage.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can I use system prompts to stop CrewAI from deleting rows?
No, system prompts are only suggestions for the AI model. A confused model or a bad user prompt can still trigger a delete query. You must enforce delete blocks at the database or query level.
What happens in CrewAI when CockroachDB blocks a delete query?
CockroachDB returns a permission error to the agent tool. The CrewAI agent reads this error message and knows the action failed. It can then try a safe query or stop the task.
Should every agent in a crew share one CockroachDB role?
No, sharing one role makes it hard to track which agent ran a query. Give read-only roles to research agents and restricted write roles to action agents. This limits damage if one agent makes a mistake.
Related guides
In this post