How to Configure AutoGen ClickHouse Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an autogen clickhouse sandbox by creating a limited database user for your AI agents. Next, you attach strict SQL read rules, row policies, and quotas to that account. Many teams start by giving agents a broad database account during early testing. That shortcut causes major trouble when an agent writes bad queries or reads private tables. Setting up an autogen clickhouse sandbox with native SQL rules ClickHouse treats users, roles, row policies, settings profiles, and quotas as SQ

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 an autogen clickhouse sandbox by creating a limited database user for your AI agents. Next, you attach strict SQL read rules, row policies, and quotas to that account. Many teams start by giving agents a broad database account during early testing. That shortcut causes major trouble when an agent writes bad queries or reads private tables.

Setting up an autogen clickhouse sandbox with native SQL rules

ClickHouse treats users, roles, row policies, settings profiles, and quotas as SQL objects. To turn on SQL access control, an admin sets a storage directory on the server. At least one admin account must also hold permission to manage access and named collections. That admin can only hand out rights that they already own themselves.

When you create the agent account, you need the right to create users. In that step, you pick how the agent logs in and which hosts it uses. You also assign default roles and user settings right away. For an AutoGen setup, teams put the query tool inside a local code runner. The agent writes a query, and the runner sends it to the database using that account.

To keep the agent inside safe bounds, you grant read rights on specific columns only. When you grant access to just two columns, the agent can query only those two fields. If the agent tries to read a third column, the database blocks the query. A wildcard query for all columns also fails unless the table holds only the allowed columns. Newer ClickHouse versions also let you grant read rights across table name prefixes using a star.

What native roles solve and what they miss

Native ClickHouse roles and column grants stop an agent from reading off-limits tables or dropping data. Quotas and settings profiles also help limit how much memory or time an agent query uses. This native setup decides which account logs in and which objects it can touch.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Yet static database rules do not check what an individual query does in flight. Suppose an agent needs to read a customer table that holds emails and phone numbers. Column grants are all-or-nothing, so an allowed column returns raw text to the agent prompt. Static roles also require you to store database keys inside the agent runner. If an agent loops or builds a strange join, database roles cannot pause the single command for human review. You also lack a unified log that ties the agent user to the exact SQL statement.

Handling sensitive fields in agent query results

AI agents often need table structure and sample rows to answer support or billing questions. If those rows include card numbers or national IDs, raw query results send private data to the model. Building copies of every table with fake data takes hours of extra work each week. Teams need a way to rewrite sensitive fields in results before the agent reads them.

Check ClickHouse queries and results before execution

Access control in ClickHouse is essential setup. Setup alone does not check single queries for risk or rewrite sensitive strings in returned rows. By design, hoop.dev sits beside the server as a sidecar for your ClickHouse and parses every statement before execution.

First, hoop.dev guardrails block disallowed deletes, drops, and alter mutations. Then hoop.dev data masking rewrites sensitive string columns in responses and logs each decision per resource. Read the docs and source on GitHub.

Frequently asked questions

Why do wildcard queries fail in a restricted ClickHouse sandbox?

When you grant read rights on specific columns only, ClickHouse blocks wildcard queries on that table. The query only works if the user has read rights on every single column in the table.

How do you limit where the AutoGen runner logs in from?

When you create the user in ClickHouse, you define the allowed host list in the statement. The database then drops login attempts from any IP address or host outside that list.

Can a ClickHouse sandbox user grant its own permissions to another agent?

No, a user can only grant rights that they hold and have permission to manage. A read-only sandbox account cannot create new users or expand its own table access.

The query runs. The emails stay hidden.