How to Configure CrewAI ClickHouse Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a crewai clickhouse prevent delete rule, create a read-only database user. Then give that user role to your AI agent workers so they cannot remove rows. Many teams start by giving agents a shared admin key to move fast. Broad permissions let a bad prompt wipe out whole tables in seconds. One wrong query from an autonomous task can drop data that took months to collect. How crewai clickhouse prevent delete works with native roles ClickHouse manages users, roles, row policies, setting

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 a crewai clickhouse prevent delete rule, create a read-only database user. Then give that user role to your AI agent workers so they cannot remove rows. Many teams start by giving agents a shared admin key to move fast. Broad permissions let a bad prompt wipe out whole tables in seconds. One wrong query from an autonomous task can drop data that took months to collect.

How crewai clickhouse prevent delete works with native roles

ClickHouse manages users, roles, row policies, settings profiles, and quotas as access items. You can create and manage all of these items with SQL statements. First, you must turn on SQL-driven access control on the database server. This setup needs a storage folder and an admin user with management rights. In ClickHouse, a user can only grant the rights that they already hold. Creating a new user also requires the specific right to create users.

When you make the user for your agent, you set the login method. You can also limit which hosts the agent user may log in from. Next, you assign default roles and per-user settings to lock down the account. Instead of giving delete rights, you grant read rights on specific tables. You can even grant read rights on single columns inside a table. If an agent queries a column outside its grant, the database blocks the query. A full table read with a wildcard also fails unless all columns are allowed. Newer database versions even let you grant rights across table names sharing a prefix.

Why static database roles leave an operational gap

Native roles are a good first step for stopping simple delete commands. They decide who can log in and which tables that account can read. Still, static database grants do not check what happens inside an active session. An agent with read rights can still run a massive join that locks memory. It can also pull raw emails, phone numbers, card numbers, or national IDs. Once those fields enter the agent memory, they often end up in external logs.

Sharing one static database key across many agent workers also hurts your audit trail. When a bad query hits the cluster, the database log shows one shared user. Your team cannot tell which person or task triggered that specific agent run. If an agent needs a rare write action, teams often grant broad write rights. Native roles cannot pause a single risky statement to ask a human for approval. You must choose between blocking all writes or risking a bad mutation in production.

ClickHouse Access Management + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

How to tighten agent database sessions in production

Start by removing shared admin keys from your agent code and task files. Create a distinct database role that holds only the read grants the task needs. Limit column grants so the agent only reads the fields required for its job. Set quotas on the database role to cap how much compute one run uses. Finally, review your query logs each week to spot strange queries from your agents. When your team needs finer control over live queries, look beyond static database grants.

Check ClickHouse queries and result columns on the wire

ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.

Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.

Frequently asked questions

Can a ClickHouse user grant delete rights to a CrewAI agent?

A ClickHouse user can only grant rights that they already hold themselves. If the setup account lacks delete rights, it cannot give them to an agent.

What happens if a CrewAI agent runs a wildcard query on restricted columns?

ClickHouse blocks a wildcard select unless the user has rights on every single column. The query fails and returns no data at all to the agent worker.

Why are read-only roles not enough for AI agents in production?

Read-only roles stop deletes, but they do not mask sensitive fields in query results. Thus, raw card numbers or emails can still leak into model prompts and logs.

The query runs. The emails stay hidden.