How to Configure OpenHands ClickHouse Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an openhands clickhouse sandbox by creating a restricted database user for the agent. Then you limit that user to specific hosts, tables, and columns with SQL grants. Many teams start by giving their coding agent a standard developer login to speed up testing. That broad login lets an automated loop read private tables or drop data by mistake. A safer setup pairs container isolation in OpenHands with strict user rules inside ClickHouse. How to set up an openhands clickhouse sandbox

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 openhands clickhouse sandbox by creating a restricted database user for the agent. Then you limit that user to specific hosts, tables, and columns with SQL grants. Many teams start by giving their coding agent a standard developer login to speed up testing. That broad login lets an automated loop read private tables or drop data by mistake. A safer setup pairs container isolation in OpenHands with strict user rules inside ClickHouse.

How to set up an openhands clickhouse sandbox

OpenHands runs its coding tasks inside an isolated workspace container. When the agent needs to check data, it sends queries from that workspace to ClickHouse. Your first step is turning on SQL-driven access control inside your ClickHouse server. This feature needs a storage folder path set in the server files. You also need at least one admin account with user management rights turned on.

Once SQL management is active, the admin creates a dedicated user for the OpenHands container. ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. When you create the agent user, you pick a login method and set allowed client hosts. Locking the host setting to the OpenHands container network stops outside machines from using that login. You can also attach a default role and custom user settings right when you make the user. Remember that an admin can only grant rights that they already hold themselves.

Next, you lock down what the agent can read. Instead of giving full table access, you can grant read rights on specific columns only. If a table holds ten columns, you can grant the agent read rights on just two. The agent can then query those two columns, and the database blocks queries on the rest. ClickHouse also blocks wildcard select queries unless the user has rights on every column in that table. In newer versions since 24.10, you can also grant rights across tables that share a name prefix.

What native database roles solve and what they leave open

Native ClickHouse roles and column grants do a great job of limiting who can log in. They also draw hard lines around which tables and columns the OpenHands agent can touch. If the agent tries to read a blocked column, the database stops the query right away. Quotas and settings profiles also help keep a runaway agent loop from using all your server memory.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static database grants only check permissions at the table or column level. Once you allow a column for debugging, the agent gets every value stored inside that column. Native grants do not rewrite sensitive patterns like emails, phone numbers, or card numbers inside query results. Also, the OpenHands container has to hold a database password or key to log in. If a prompt flaw tricks the agent, it could print that stored secret into its task logs. Finally, native roles cannot pause a risky query to ask a human for approval in real time.

Managing credentials and query results for AI agents

Teams running autonomous agents need more than static user accounts to keep production data safe. First, keep long-lived database keys out of the agent container so tasks cannot leak them. Second, inspect query results in flight and mask fields like national IDs, emails, and phone numbers. Rewriting matched fields in results lets the agent test schemas without pulling raw personal data into prompts. Third, log every SQL statement alongside the agent identity so your team can audit what ran.

Add runtime guardrails and masking beside ClickHouse

Database grants and network rules control who can reach ClickHouse. Even so, an allowed client or agent can send an alter mutation that deletes rows or read raw personal data. In practice, hoop.dev runs beside the server as a sidecar for your ClickHouse and checks native TCP queries with no change to your drivers.

With hoop.dev ClickHouse support, guardrails refuse banned queries before they run, and data masking rewrites matched string columns in results. The audit trail logs which entity types were masked and how many without storing raw values. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Why did my wildcard query fail in the OpenHands ClickHouse sandbox?

ClickHouse blocks wildcard select queries when a user only has rights on specific columns. Update the agent prompt to name the exact allowed columns in every select statement.

How do I stop the agent login from working outside the sandbox?

Set the allowed host rule when you create the ClickHouse user with SQL. Limit the host to the exact IP address or network of your OpenHands container.

Can a ClickHouse user grant extra rights to the OpenHands agent?

A user can only grant privileges that they hold themselves, and creating users takes a specific privilege. Keep user management rights turned off for the account that OpenHands uses.

The query runs. The emails stay hidden.