How to Configure CrewAI ClickHouse Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a crewai clickhouse sandbox by creating a read-only database user and role. Then you give your AI agent those restricted login details so it can run queries. Teams often start by handing an agent a shared database login. That shortcut creates big risks when an agent writes bad SQL. Overly broad permissions let a confused agent read private tables or run heavy queries. A proper sandbox limits what tables and columns the agent can touch. How a native crewai clickhouse sandbox works C

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.

You set up a crewai clickhouse sandbox by creating a read-only database user and role. Then you give your AI agent those restricted login details so it can run queries. Teams often start by handing an agent a shared database login. That shortcut creates big risks when an agent writes bad SQL. Overly broad permissions let a confused agent read private tables or run heavy queries. A proper sandbox limits what tables and columns the agent can touch.

How a native crewai clickhouse sandbox works

ClickHouse manages users, roles, row policies, settings profiles, and quotas as access entities. You create and change these entities with standard SQL commands. First, your server needs SQL-driven access control turned on. That requires a storage folder on the server and an admin user with management rights. In ClickHouse, an admin can only grant privileges that they already hold themselves.

Once SQL access control is active, you create a dedicated user for your CrewAI agent. The user creation step sets the login method, allowed client hosts, and default roles. It also attaches per-user settings to cap memory or query time. Next, you grant read permissions on specific tables or columns. ClickHouse lets you grant select rights on single columns rather than a whole table. If an agent runs a wildcard select query, ClickHouse blocks the query and returns nothing. The wildcard query only works if the agent has rights to every column in that table. Since version 24.10, you can also grant rights across tables that share a name prefix.

What native database roles solve and what they miss

Native ClickHouse roles and column grants stop an agent from reading unauthorized tables. Row policies and quotas also help keep resource use in check at the database level. These built-in tools decide who can log in and which objects they can query. They form a solid baseline for any agent workflow that generates SQL.

Still, static database grants leave a major operational gap open during live agent runs. Once the agent logs in, the database allows any query that matches the granted columns. If a permitted column holds emails, phone numbers, or card numbers, the query returns them raw. Those raw values flow right into the agent context and out to your model provider. Also, when ten agents share one database user, server logs show only that single login. You cannot tell which specific user or task triggered a slow or risky query. Native roles check login rights at the door, not what individual statements return in flight.

ClickHouse Access Management + AI Sandbox Environments: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

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

Why does a wildcard query fail for a restricted ClickHouse agent user?

ClickHouse blocks wildcard select queries when a user only has grants on specific columns. The agent must name the exact allowed columns in its query to get data back.

How do you turn on SQL-driven access control in ClickHouse?

You set the access control storage path in your server settings file. You also enable access management rights on at least one initial admin account.

Can a ClickHouse user grant permissions to another agent role?

A user needs specific grant rights to share permissions with other roles. Even then, a user can only grant privileges that they already hold on their own account.

The query runs. The emails stay hidden.