How to Configure OpenHands ClickHouse Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up openhands clickhouse prevent delete rules, create a database role without delete rights. Assign that restricted role to the database user that your coding agent uses. Many teams connect AI agents like OpenHands to data stores using shared admin keys. An agent with broad rights can drop tables or erase rows by mistake. One bad prompt or loop can wipe out vital records in seconds. Setting strict user limits stops the agent from running destructive commands. How openhands clickhouse pr

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 openhands clickhouse prevent delete rules, create a database role without delete rights. Assign that restricted role to the database user that your coding agent uses.

Many teams connect AI agents like OpenHands to data stores using shared admin keys. An agent with broad rights can drop tables or erase rows by mistake. One bad prompt or loop can wipe out vital records in seconds. Setting strict user limits stops the agent from running destructive commands.

How openhands clickhouse prevent delete works in native SQL

ClickHouse manages users, roles, row policies, settings profiles, and quotas through SQL commands. To turn on SQL access control, you first set a storage directory on the server. You also need at least one user with access management turned on. Once active, an admin can create a dedicated user account for OpenHands.

When you create this user, you set how it logs in. You can also limit which hosts the agent can connect from. In ClickHouse, a user can only grant rights that they already hold. To block deletions, you grant read or insert rights while leaving out delete permissions.

You can lock down read queries down to single columns. For example, you can grant read access on just two specific columns in a table. The agent can then query those two columns, but nothing else in that table. If the agent tries to select all columns with a wildcard, the query fails. ClickHouse returns no data unless the table holds only the permitted columns. Starting in version 24.10, a trailing asterisk lets you grant rights by table name prefix.

What native roles solve and what they leave open

Native roles and grants decide who can log in and which tables they can touch. If OpenHands uses a role without delete rights, the database rejects delete statements. This basic setup stops simple mistakes from wiping out full tables. It also keeps the agent confined to specific host addresses and database prefixes.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, static database roles leave big operational gaps for teams running AI agents. First, the agent app needs a stored password or key in its local workspace. Because OpenHands runs code and shell tools, the agent can read its own config files. Second, column grants are rigid and break when schemas change or agents run wildcard queries. If a table holds emails, phone numbers, card numbers, or national IDs, grants are blunt. You must either block the whole column or expose raw values in every query result. Data masking is better because it rewrites matched fields in results on the fly.

Why query-level controls matter for autonomous agents

Database roles apply the same static rules to every session from that user account. They cannot ask a human for approval when an agent needs a one-time fix. If an engineer grants temporary write rights to fix a bug, those rights often stay on. Static user settings also lack a clear audit trail tying queries to a specific task.

When an AI agent writes and runs SQL on its own, session checks are not enough. Teams need to inspect each statement in flight before it reaches the database server. You want to block risky mutations, mask sensitive fields, and log every query with full context. Separating credential storage from the agent runtime keeps your database safe during automated tasks.

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

How do I stop OpenHands from deleting rows in ClickHouse?

Create a dedicated ClickHouse user for OpenHands using SQL access control. Grant that user only select and insert rights, and leave out delete permissions.

What happens if OpenHands runs a wildcard query on restricted columns?

ClickHouse blocks wildcard select queries when a user only has grants on specific columns. The query returns no data unless the table contains only those granted columns.

Can ClickHouse restrict which hosts OpenHands connects from?

Yes, the user creation command in ClickHouse lets you define allowed client hosts. The database will reject login attempts from the agent if they come from other machines.

The query runs. The emails stay hidden.